dom4j-xml字符串生成XML文件

 public void createXMLFile(String xmlText) {
  try {
   OutputFormat format = OutputFormat.createPrettyPrint();
   format.setEncoding("GBK");
   log.info("receive message:/n"+xmlText);
   XMLWriter xmlWriter = new XMLWriter(new FileOutputStream("c://sale.xml"), format);
   Document doc = DocumentHelper.parseText(xmlText);
   xmlWriter.write(doc);
   xmlWriter.close();
  } catch (Exception e) {
   e.printStackTrace();
  }
 }

你可能感兴趣的:(c,xml,exception,String)