/** * 格式化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); } }
??
(编辑:李大同)
【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!
|