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寫入一個文件,一切都很好,但是在最後一個結束標記前面添加了一行,如下所示。寫xml錯誤
[Mar 13 15:40:16] INFO (ConnectionController.java:342) -
我正在NEER使用這個類,爲什麼這個年03月13日期甚至我不知道
它是一個常見的問題?
你需要接受一些你老問題的答案 – willcodejavaforfood 2010-07-20 12:10:21
我會在拼寫和語法方面多花點功夫,因爲其他人需要閱讀這篇文章。 – 2010-07-20 12:11:34