本文整理了Java中org.dom4j.io.OutputFormat.setEncoding()
方法的一些代码示例,展示了OutputFormat.setEncoding()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。OutputFormat.setEncoding()
方法的具体详情如下:
包路径:org.dom4j.io.OutputFormat
类名称:OutputFormat
方法名:setEncoding
[英]DOCUMENT ME!
[中]记录我!
代码示例来源:origin: org.dom4j/dom4j
public void write(Writer out) throws IOException {
OutputFormat format = new OutputFormat();
format.setEncoding(encoding);
XMLWriter writer = new XMLWriter(out, format);
writer.write(this);
}
代码示例来源:origin: webx/citrus
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();
}
代码示例来源:origin: webx/citrus
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();
}
代码示例来源:origin: webx/citrus
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();
}
代码示例来源:origin: org.dom4j/dom4j
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());
}
}
代码示例来源:origin: mrdear/JavaWEB
/**
* 把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();
}
代码示例来源:origin: webx/citrus
/** 输出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();
}
代码示例来源:origin: webx/citrus
/** 输出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();
}
代码示例来源:origin: webx/citrus
/** 输出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();
}
代码示例来源:origin: youseries/urule
Document doc=DocumentHelper.parseText(sb.toString());
OutputFormat format=OutputFormat.createPrettyPrint();
format.setEncoding("utf-8");
XMLWriter writer=new XMLWriter(out,format);
writer.write(doc);
代码示例来源:origin: org.dom4j/dom4j
setExpandEmptyElements(true);
} else if (args[i].equals("-encoding")) {
setEncoding(args[++i]);
} else if (args[i].equals("-newlines")) {
setNewlines(true);
代码示例来源:origin: org.mule.modules/mule-module-xml
/**
* @see OutputFormat#setEncoding(String)
*/
@Override
public synchronized void setEncoding(String encoding)
{
outputFormat.setEncoding(encoding);
}
代码示例来源:origin: pentaho/pentaho-kettle
format.setEncoding( "iso-8859-1" );
} else {
format.setEncoding( meta.getEncoding() );
代码示例来源:origin: dom4j/dom4j
public void write(Writer out) throws IOException {
OutputFormat format = new OutputFormat();
format.setEncoding(encoding);
XMLWriter writer = new XMLWriter(out, format);
writer.write(this);
}
代码示例来源:origin: org.dom4j/com.springsource.org.dom4j
public void write(Writer out) throws IOException {
OutputFormat format = new OutputFormat();
format.setEncoding(encoding);
XMLWriter writer = new XMLWriter(out, format);
writer.write(this);
}
代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.dom4j
public void write(Writer out) throws IOException {
OutputFormat format = new OutputFormat();
format.setEncoding(encoding);
XMLWriter writer = new XMLWriter(out, format);
writer.write(this);
}
代码示例来源:origin: org.alfresco/alfresco-repository
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;
}
代码示例来源:origin: dom4j/dom4j
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);
}
代码示例来源:origin: dom4j/dom4j
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());
}
代码示例来源:origin: dom4j/dom4j
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());
}
内容来源于网络,如有侵权,请联系作者删除!