Example usage for org.jdom2.output LineSeparator CRNL

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

Introduction

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

Prototype

LineSeparator CRNL

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

Click Source Link

Document

The Separator sequence CRNL which is '\r\n'.

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;// w  w  w  .  java2s  . co  m
        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);
    }
}