/**
* 格式化XML文档,并解决中文问题
* @param filename
* @return
*/
public static void formatXMLFile(File xmlFile) {
try {
SAXReader saxReader = new SAXReader();
Document document = saxReader.read(xmlFile);
XMLWriter output = null;
/** 格式化输出,类型IE浏览一样 */
OutputFormat format = OutputFormat.createPrettyPrint();
format.setEncoding("UTF-8");
output = new XMLWriter(new FileWriter(xmlFile),format);
output.write(document);
output.close();
} catch (Exception e) {
logger.error("Obj2XMLFile() change to xml fail," + e.toString());
throw new CmsCommonException(CmsCommonErrCodes.CLASSCAST_ERROR);
}
}