org.xml.sax.SAXParseException: Invalid byte 1 of 1-byte UTF-8 sequence.
这个问题的解决:
// 生成的xml的格式
OutputFormat format = OutputFormat.createPrettyPrint();
// 生成的xml文档路径
String path = "D:/Documents and Settings/Administrator/workspace/GDS/config/graph/gisproducts/S002.xml";
把:
XMLWriter writer = new XMLWriter(new FileWriter(path), format);
改成如下:就可以了
XMLWriter writer = new XMLWriter(new FileOutputStream(path), format);
写的够简洁吧,呵呵!
这个问题的解决:
// 生成的xml的格式
OutputFormat format = OutputFormat.createPrettyPrint();
// 生成的xml文档路径
String path = "D:/Documents and Settings/Administrator/workspace/GDS/config/graph/gisproducts/S002.xml";
把:
XMLWriter writer = new XMLWriter(new FileWriter(path), format);
改成如下:就可以了
XMLWriter writer = new XMLWriter(new FileOutputStream(path), format);
写的够简洁吧,呵呵!
本文介绍了一个关于XML生成过程中出现的UTF-8编码错误问题及解决方案。通过将文件写入方式从FileWriter改为FileOutputStream,成功解决了org.xml.sax.SAXParseException异常。
1075

被折叠的 条评论
为什么被折叠?



