public void write(Writer out) throws IOException { OutputFormat format = new OutputFormat(); format.setEncoding(encoding); XMLWriter writer = new XMLWriter(out, format); writer.write(this); }
private static void writeDocument(Document doc, OutputStream stream) throws IOException { String charset = "UTF-8"; Writer writer = new OutputStreamWriter(stream, charset); OutputFormat format = new OutputFormat(); format.setEncoding(charset); XMLWriter xmlWriter = new XMLWriter(writer, format); xmlWriter.write(doc); xmlWriter.flush(); }
private static void writeDocument(Document doc, OutputStream stream) throws IOException { String charset = "UTF-8"; Writer writer = new OutputStreamWriter(stream, charset); OutputFormat format = new OutputFormat(); format.setEncoding(charset); XMLWriter xmlWriter = new XMLWriter(writer, format); xmlWriter.write(doc); xmlWriter.flush(); }
private static void writeDocument(Document doc, OutputStream stream) throws IOException { String charset = "UTF-8"; Writer writer = new OutputStreamWriter(stream, charset); OutputFormat format = new OutputFormat(); format.setEncoding(charset); XMLWriter xmlWriter = new XMLWriter(writer, format); xmlWriter.write(doc); xmlWriter.flush(); }
public String asXML() { OutputFormat format = new OutputFormat(); format.setEncoding(encoding); try { StringWriter out = new StringWriter(); XMLWriter writer = new XMLWriter(out, format); writer.write(this); writer.flush(); return out.toString(); } catch (IOException e) { throw new RuntimeException("IOException while generating textual " + "representation: " + e.getMessage()); } }
/** * 把document对象写入新的文件 * * @param document * @throws Exception */ public static void writer(Document document, OutputStreamWriter outputStream, String encoding) throws Exception { OutputFormat format = OutputFormat.createPrettyPrint(); format.setEncoding(encoding); XMLWriter writer = new XMLWriter(outputStream, format); writer.write(document); writer.flush(); writer.close(); }
/** 输出DOM。 */ public static void writeDocument(Document doc, Writer writer, String charset) throws IOException { charset = defaultIfEmpty(trimToNull(charset), "UTF-8"); OutputFormat format = OutputFormat.createPrettyPrint(); format.setEncoding(charset); format.setIndent(true); format.setIndentSize(4); XMLWriter xmlWriter = new XMLWriter(writer, format); xmlWriter.write(doc); xmlWriter.flush(); }
/** 输出DOM。 */ public static void writeDocument(Document doc, Writer writer, String charset) throws IOException { charset = defaultIfEmpty(trimToNull(charset), "UTF-8"); OutputFormat format = OutputFormat.createPrettyPrint(); format.setEncoding(charset); format.setIndent(true); format.setIndentSize(4); XMLWriter xmlWriter = new XMLWriter(writer, format); xmlWriter.write(doc); xmlWriter.flush(); }
/** 输出DOM。 */ public static void writeDocument(Document doc, Writer writer, String charset) throws IOException { charset = defaultIfEmpty(trimToNull(charset), "UTF-8"); OutputFormat format = OutputFormat.createPrettyPrint(); format.setEncoding(charset); format.setIndent(true); format.setIndentSize(4); XMLWriter xmlWriter = new XMLWriter(writer, format); xmlWriter.write(doc); xmlWriter.flush(); }
Document doc=DocumentHelper.parseText(sb.toString()); OutputFormat format=OutputFormat.createPrettyPrint(); format.setEncoding("utf-8"); XMLWriter writer=new XMLWriter(out,format); writer.write(doc);
setExpandEmptyElements(true); } else if (args[i].equals("-encoding")) { setEncoding(args[++i]); } else if (args[i].equals("-newlines")) { setNewlines(true);
/** * @see OutputFormat#setEncoding(String) */ @Override public synchronized void setEncoding(String encoding) { outputFormat.setEncoding(encoding); }
format.setEncoding( "iso-8859-1" ); } else { format.setEncoding( meta.getEncoding() );
public void write(Writer out) throws IOException { OutputFormat format = new OutputFormat(); format.setEncoding(encoding); XMLWriter writer = new XMLWriter(out, format); writer.write(this); }
public void write(Writer out) throws IOException { OutputFormat format = new OutputFormat(); format.setEncoding(encoding); XMLWriter writer = new XMLWriter(out, format); writer.write(this); }
public void write(Writer out) throws IOException { OutputFormat format = new OutputFormat(); format.setEncoding(encoding); XMLWriter writer = new XMLWriter(out, format); writer.write(this); }
private XMLWriter createXMLExporter(Writer writer) { // Define output format OutputFormat format = OutputFormat.createPrettyPrint(); format.setNewLineAfterDeclaration(false); format.setIndentSize(3); format.setEncoding("UTF-8"); // Construct an XML Exporter XMLWriter xmlWriter = new XMLWriter(writer, format); return xmlWriter; }
protected void testEncoding(String encoding) throws Exception { ByteArrayOutputStream out = new ByteArrayOutputStream(); OutputFormat format = OutputFormat.createPrettyPrint(); format.setEncoding(encoding); XMLWriter writer = new XMLWriter(out, format); writer.write(document); writer.close(); log("Wrote to encoding: " + encoding); }
public void testRussian() throws Exception { Document doc = getDocument("/xml/russArticle.xml"); assertEquals("encoding not correct", "koi8-r", doc.getXMLEncoding()); Element el = doc.getRootElement(); StringWriter writer = new StringWriter(); XMLWriter xmlWriter = new XMLWriter(writer); OutputFormat format = OutputFormat.createPrettyPrint(); format.setEncoding("koi8-r"); xmlWriter.write(doc); log(writer.toString()); }
public void testRussian() throws Exception { File file = getFile("/xml/russArticle.xml"); XPP3Reader xmlReader = new XPP3Reader(); Document doc = xmlReader.read(file); Element el = doc.getRootElement(); StringWriter writer = new StringWriter(); XMLWriter xmlWriter = new XMLWriter(writer); OutputFormat format = OutputFormat.createPrettyPrint(); format.setEncoding("koi8-r"); xmlWriter.write(doc); log(writer.toString()); }