首先获取文件相对路径
然后采用此方法
XMLOutputter xmlOutPutter=new XMLOutputter();
xmlOutPutter.setFormat (Format.getPrettyFormat ());
FileOutputStream fileOutputStream=new FileOutputStream(filepath+"/WEB-INF/reportStyleConfig.xml");
xmlOutPutter.output(doc,fileOutputStream);
转载于:https://blog.51cto.com/boysky/974161