解决解析xml报UTFDataFormatException方案

前端之家收集整理的这篇文章主要介绍了解决解析xml报UTFDataFormatException方案前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

解析XML报错:

UTFDataFormatException: invalid byte 2 of 2-byte UTF-8 sequence (0xfa)

解决方案:

SAXReader reader = new SAXReader();
org.dom4j.Document document = reader.read(new ByteArrayInputStream(s.getBytes());

改成:

SAXReader reader = new SAXReader();
org.dom4j.Document document = reader.read(new ByteArrayInputStream(s.getBytes("UTF-8")));

原文链接:https://www.f2er.com/xml/296354.html

猜你在找的XML相关文章