//设置集合接受 设备信息
File f=new File("recordInfo.xml");
String readin="";
InputStreamReader read=new InputStreamReader(in);
BufferedReader bureader =new BufferedReader(read);
ArrayList list =new ArrayList();
OutputStream out;
try {
out = new FileOutputStream(f);
//读取数据和输出数据
while((readin=bureader.readLine())!=null)
{
log.info("获取的xml文件:"+readin);
out.write(readin.getBytes("utf-8"));
}
log.info("文件路径:"+f.getAbsolutePath());
//解析传过来的xml
SAXReader sax=new SAXReader();
sax.setEncoding("utf-8");
Document doc=sax.read(f);
dom4j解析xml用输出流保存
最新推荐文章于 2022-08-23 23:19:54 发布
这篇博客介绍了如何使用dom4j解析XML文件,并通过OutputStream将内容以UTF-8编码保存。首先,从文件中读取XML数据,然后通过BufferedReader逐行读取并写入OutputStream。接着,使用SAXReader进行解析,获取XML文档的根元素和特定子节点。最后,遍历子节点进行进一步处理。
摘要由CSDN通过智能技术生成