Example usage for org.jdom2.output LineSeparator NL

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

Introduction

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

Prototype

LineSeparator NL

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

Click Source Link

Document

The Separator sequence NL which is '\n'.

Usage

From source file:com.github.cat.yum.store.util.YumUtil.java

private static void xmlToFile(Document doc, File outfile) throws IOException {
    FileOutputStream fileOutputStream = null;
    try {/*from   w  w w . j a  v  a2s  .c om*/
        Format formate = Format.getPrettyFormat();
        formate.setOmitEncoding(true);
        formate.setLineSeparator(LineSeparator.NL);
        // System.out.println(new XMLOutputter(formate).outputString(doc));
        fileOutputStream = new FileOutputStream(outfile, false);
        new XMLOutputter(formate).output(doc, fileOutputStream);
    } finally {
        try {
            if (null != fileOutputStream) {
                fileOutputStream.close();
            }
        } catch (IOException ignore) {

        }
    }
}

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 ww w  .  java2  s.c  o  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);
    }
}