/** * 字符串,
生成xml
文件 * @p
aram str * @p
aram fileName * @throws IOException */ public void strChangeXML(String str,String fileName ) throws IOException { SAXReader saxReader = new SAXReader(); Document document; try { document = saxReader.read(new ByteArrayInputStream(str.getBytes())); OutputFormat format = OutputFormat.createPrettyPrint(); /** 指定XML字符集编码 */ format.setEncoding("UTF-8"); /** 将document中的
内容写入
文件中 */ XMLWriter writer = new XMLWriter(new FileWriter(new File(fileName)),format); writer.write(document); writer.close(); } catch (DocumentException e) { // T
odoAuto-generatedcatchblock logger.error(e.getMessage()); } }