【发布时间】:2010-07-20 12:07:34
【问题描述】:
public static void writeXmlFile(Document doc, String filename) {
try {
// Prepare the DOM document for writing
Source source = new DOMSource(doc);
// Prepare the output file
File file = new File(filename);
Result result = new StreamResult(file);
// Write the DOM document to the file
Transformer xformer = TransformerFactory.newInstance()
.newTransformer();
xformer.transform(source, result);
} catch (TransformerConfigurationException e) {
} catch (TransformerException e) {
}
}
我正在使用此函数将 xml 写入文件,一切正常,但在最后一个结束标记之前添加了一行,如下所示。
[Mar 13 15:40:16] INFO (ConnectionController.java:342) -
我不喜欢使用这个课程,为什么这个日期是 3 月 13 日,即使我也不知道
这是一个常见问题吗?
【问题讨论】:
-
您需要接受一些旧问题的答案
-
我会在拼写和语法上多花点功夫,因为其他人需要阅读这篇文章。