List of usage examples for org.jdom2.output Format setOmitEncoding
public Format setOmitEncoding(boolean omitEncoding)
<?xml version="1.0" encoding="UTF-8"?>
) includes the encoding of the document. 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 va2s .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:nl.colorize.util.xml.XMLHelper.java
License:Apache License
private static XMLOutputter getOutputter() { Format formatter = Format.getPrettyFormat(); formatter.setEncoding(Charsets.UTF_8.displayName()); formatter.setIndent(" "); formatter.setLineSeparator(Platform.getLineSeparator()); formatter.setExpandEmptyElements(false); formatter.setOmitDeclaration(false); formatter.setOmitEncoding(false); XMLOutputter outputter = new XMLOutputter(formatter); outputter.setFormat(formatter);/*from w ww . j a v a2 s . c om*/ return outputter; }