[JAVA] IOException: Invalid byte 2 of 2-byte UTF-8 sequence (solution), ioexception2-byte
Log printing is incomplete. Only the title exception information is printed in the background:
Previous log print information: log. debug (e. getMessage ());
Log. debug (e); log. debug (e. getStackTrace ());
The importance of log printing cannot only print messages
Find the cause of the problem. This problem occurs in the Payment Protection Function. After finding the cause on the Internet, the following Connection provides the most accurate information:
Http://blog.csdn.net/linkyou/article/details/3975491
The root cause is the following code:
public static InputStream String2Inputstream(String str) throws IOException { return new ByteArrayInputStream(str.getBytes("UTF-8")); }
Add the UTF-8 in getBytes. The root cause is that the encoding method on our server is GBK. At this time, when getBytes is obtained, the encoding method on the server is obtained, and an error is reported.
Conclusion: encoding is a key concern when string and binary stream conversion are involved anywhere. All encoding methods must be determined, rather than taken from the server, unified management of coding methods is king. At the same time, I can only sigh, but I am used to it ~
When xml parsing changes, Invalid byte 2 of 2-byte UTF-8 sequence
The landlord is a good guy, but it is estimated that no one birds you. Alas, it is better to believe in books than to have no books.
The error "orgxmlsaxSAXParseException" is reported during xml parsing:
Use the text editing tool to look at it with a UTF-8. Xml Error