DMM4J生成xml文件无换行问题

//读取文件  
  FileWriter fileWriter = new FileWriter(outFile);  
//设置文件编码  
  OutputFormat xmlFormat = OutputFormat.createPrettyPrint();  
   xmlFormat.setEncoding("UTF-8");
   //xmlFormat.setTrimText(false);//设置text中是否要删除其中多余的空格   
  XMLWriter xmlWriter = new XMLWriter(fileWriter,xmlFormat);
//写入文件  
  xmlWriter.write(document);  
//关闭  
  xmlWriter.close();  

 

OutputFormat.createPrettyPrint();  缩减型格式

createCompactFormat(); 紧凑型格式

你可能感兴趣的:(xml)