Example usage for org.jdom2.output LineSeparator CR

List of usage examples for org.jdom2.output LineSeparator CR

Introduction

In this page you can find the example usage for org.jdom2.output LineSeparator CR.

Prototype

LineSeparator CR

To view the source code for org.jdom2.output LineSeparator CR.

Click Source Link

Document

The Separator sequence CR which is '\r'.

Usage

From source file:org.commonjava.maven.ext.io.PomIO.java

License:Apache License

private static LineSeparator determineEOL(File pom) throws ManipulationException {
    try (BufferedInputStream bufferIn = new BufferedInputStream(new FileInputStream(pom))) {
        int prev = -1;
        int ch;//from  w  w  w. ja  v  a2  s. com
        while ((ch = bufferIn.read()) != -1) {
            if (ch == '\n') {
                if (prev == '\r') {
                    return LineSeparator.CRNL;
                } else {
                    return LineSeparator.NL;
                }
            } else if (prev == '\r') {
                return LineSeparator.CR;
            }
            prev = ch;
        }
        throw new ManipulationException("Could not determine end-of-line marker mode");
    } catch (IOException ioe) {
        throw new ManipulationException("Could not determine end-of-line marker mode", ioe);
    }
}