出现1字节的utf-8序列的字节1无效异常
使用saxReader.setEncoding("gb2312");
但是只能针对保存的不是utf-8的文件才有效,其他的会报错异常为:前言不允许有内容
此时可以在生成xml的地方进行改进
将FileWriter out = new FileWriter(".xml");
改为
new OutputStreamWriter(new FileOutputStream(".xml"),"UTF-8");
出现1字节的utf-8序列的字节1无效异常
使用saxReader.setEncoding("gb2312");
但是只能针对保存的不是utf-8的文件才有效,其他的会报错异常为:前言不允许有内容
此时可以在生成xml的地方进行改进
将FileWriter out = new FileWriter(".xml");
改为
new OutputStreamWriter(new FileOutputStream(".xml"),"UTF-8");
转载于:https://www.cnblogs.com/liwangxing-xiaotaiye/p/10174359.html