我想要将 xml 字符串转换为文件,我正在按照以下方式进行操作,
String xmlFile=responseXMLName;
log.info("xml file :" +xmlFile);
fr = new FileWriter(new File(xmlFile));
Writer br= new BufferedWriter(fr);
log.info("respose string"+responseXMLString);
br.write(responseXMLString);
br.close();
我想将 xml 文件数据传递给这个函数,我该怎么做?
Document doc = builder.build(...);
最佳答案
StringReader reader = new StringReader( s );
InputSource inputSource = new InputSource( reader );
Document doc = builder.parse( inputSource );
reader.close();
就可以了。
关于java - xml 字符串到文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1957497/