通常的做法
不能用默认的xmlWriter写
try {
org.dom4j.io.XMLWriter xmlWriter = new org.dom4j.io.XMLWriter(
new FileWriter(fileName));
xmlWriter.write(doc);
xmlWriter.close();
}
正确的做法是:不能用默认的xmlWriter写,而应该用FileOutputStream( );
try {
//注意这里的修改
org.dom4j.io.XMLWriter xmlWriter = new org.dom4j.io.XMLWriter(
new FileOutputStream(fileName));
xmlWriter.write(doc);
xmlWriter.close();
}
catch (Exception e) {
System.out.println(e);
}