Xml读取异常--Invalid byte 1 of 1-byte UTF-8 sequence
xml读取异常Invalid byte 1 of 1-byte UTF-8 sequence
org.dom4j.DocumentException: Invalid byte 1 of 1-byte UTF-8 sequence. Nested exception: Invalid byte 1 of 1-byte UTF-8 sequence
出现这个问题是在我修改过xml文件后又重新保存后读取,文件出现这个问题,先看一下出现问题的代码
FileWriter fileWriter=new FileWriter(path);//path为文件路径
XMLWriter write=new XMLWriter(fileWriter);
write.write(document);//写入流
write.close();//关闭流
查看资料是说xml的编码问题,所以对代码进行修改,修改之后如下
FileOutputStream outputStream= new FileOutputStream(path);
OutputStreamWriter writer= new OutputStreamWriter(outputStream, "utf-8"); XMLWriter write=new XMLWriter(writer,OutputFormat.createPrettyPrint());
write.write(document);
write.close();
这样问题就完美解决了
Xml读取异常--Invalid byte 1 of 1-byte UTF-8 sequence的更多相关文章
- 【BUG】xml读取异常Invalid byte 1 of 1-byte UTF-8 sequence
来自http://blog.csdn.net/chenyanbo/article/details/6866941 xml读取异常Invalid byte 1 of 1-byte UTF-8 seque ...
- xml 读取递归算法
xml 读取递归算法:
- paip.获取proxool的配置 xml读取通过jdk xml 初始化c3c0在代码中总结
paip.获取proxool的配置 xml读取通过jdk xml 初始化c3c0在代码中 xml读取通过jdk xml 初始化c3c0在代码中.. ... 作者Attilax 艾龙, EMAI ...
- Java基础知识强化之IO流笔记27:FileInputStream读取数据一次一个字节数组byte[ ]
1. FileInputStream读取数据一次一个字节数组byte[ ] 使用FileInputStream一次读取一个字节数组: int read(byte[] b) 返回值:返回值其实是实际 ...
- Linq to XML 读取XML 备忘笔记
本文转载:http://www.cnblogs.com/infozero/archive/2010/07/13/1776383.html Linq to XML 读取XML 备忘笔记 最近一个项目中有 ...
- C#基础笔记---浅谈XML读取以及简单的ORM实现
背景: 在开发ASP.NETMVC4 项目中,虽然web.config配置满足了大部分需求,不过对于某些特定业务,我们有时候需要添加新的配置文件来记录配置信息,那么XML文件配置无疑是我们选择的一个方 ...
- python 读取文件时报错UnicodeDecodeError: 'gbk' codec can't decode byte 0x80 in position 205: illegal multibyte sequence
python读取文件时提示"UnicodeDecodeError: 'gbk' codec can't decode byte 0x80 in position 205: illegal m ...
- svn checkout The XML response contains invalid XML
svn checkout 报错:The XML response contains invalid XML 待解决? ---目前没有找到好的解决方法,svn数据库中存的log入手应该可以,有时间再去看 ...
- python在读取文件时出现 'gbk' codec can't decode byte 0x89 in position 68: illegal multibyte sequence
python在读取文件时出现“UnicodeDecodeError:'gbk' codec can't decode byte 0x89 in position 68: illegal multiby ...
随机推荐
- c#播放声音文件
C#中声音的播放主要有三种方法: 1.使用API函数. 2.使用SoundPlayer类播放. 3.使用DirectX进行播放. 一.使用API函数进行播放. windows操作系统中的winmm.d ...
- rsync同步配置
因为公司数据库比较重要,现在只有一台服务器,IP为:118.145.*.*暂称为server,公司一台虚拟机,IP为.192.168.0.100 ,暂称为rsync 1.安装服务器端:yum -y i ...
- 安装centos mini版,无法联网,用yum安装软件提示 cannot find a valid baseurl for repo:base/7/x86_64 的解决方法
*无法联网的明显表现会有: cannot find a valid baseurl for repo:base/7/x86_64 1.yum install出现 Error: cannot find ...
- 解决Android ListView 和 ScrollView 共存时冲突 问题 方法其一
转载请注明出处: http://www.goteny.com/articles/2013/11/8.html http://www.cnblogs.com/zjjne/p/3428480.html 当 ...
- 转:40多个关于人脸检测/识别的API、库和软件
文章来自于:http://blog.jobbole.com/45936/ 自从谷歌眼镜被推出以来,围绕人脸识别,出现了很多争议.我们相信,不管是不是通过智能眼镜,人脸识别将在人与人交往甚至人与物交互中 ...
- 利用mongoimport命令导入csv大文件
最近我同事做了一个PHP项目,其中有一个功能是 上传excel文件并将数据导入mongodb某个集合中. 通常的做法是 写一个上传文件的页面,然后后端 读取 这个文件,利用phpexcel类库将这个e ...
- Top 100 words for advanced learners.
aberration (n.) something that differs from the norm (In 1974, Poland won the World Cup, but the suc ...
- 【转】你应该知道的 10 个 VirtualBox 技巧与高级特性
原文网址:http://www.oschina.net/translate/10-virtualbox-tricks-and-advanced-features-you-should-know-abo ...
- linux下常用FTP命令
linux下常用FTP命令 1. 连接ftp服务器 1. 连接ftp服务器格式:ftp [hostname| ip-address]a)在linux命令行下输入: ftp 192.168.1.1b)服 ...
- Java[4] Jetty工作原理介绍(转)
转自:https://www.ibm.com/developerworks/cn/java/j-lo-jetty/ Jetty 的工作原理以及与 Tomcat 的比较 Jetty 应该是目前最活跃也是 ...