/**
* Save the content of a document to the given output stream. Since
* XCES content files are plain text (not XML), XML-illegal characters
* are not replaced when writing. The stream is <i>not</i> closed by
* this method, that is left to the caller.
*
* @param doc the document to save
* @param out the stream to write to
* @param encoding the character encoding to use. If null, defaults to
* UTF-8
*/
public static void writeXcesContent(Document doc, OutputStream out,
String encoding) throws IOException {
if(encoding == null) {
encoding = "UTF-8";
}
String documentContent = doc.getContent().toString();
OutputStreamWriter osw = new OutputStreamWriter(out, encoding);
BufferedWriter writer = new BufferedWriter(osw);
writer.write(documentContent);
writer.flush();
// do not close the writer, this would close the underlying stream,
// which is something we want to leave to the caller
}
DocumentStaxUtils.java 文件源码
java
阅读 33
收藏 0
点赞 0
评论 0
项目:gate-core
作者:
评论列表
文章目录