2 回答
TA贡献1874条经验 获得超12个赞
我不确定,但可能会对您有帮助。此代码快照会将您的.xml文件转换为.docx文件。
public class ReadXmlFile {
public static void main(String[] args) throws ParserConfigurationException, SAXException, IOException {
File xmlFile = new File("inFile.xml");
Reader fileReader = new FileReader(xmlFile);
BufferedReader bufReader = new BufferedReader(fileReader);
StringBuilder sb = new StringBuilder();
String line = bufReader.readLine();
Writer out = new FileWriter("outFile.docx");
while( line != null)
{
sb.append(line).append("\n");
line = bufReader.readLine();
if(line !=null)
out.write(line);
}
out.close();
fileReader.close();
String xml2String = sb.toString();
System.out.println(xml2String);
}
}
添加回答
举报