SAXException – Invalid byte 1 of 1-byte UTF-8 sequence


Invalid byte 1 of 1-byte UTF-8 sequence:

            In My program, I was reading XML using InputStream and I was getting SAXException – Invalid byte 1 of 1-byte UTF-8 sequence, whenever I have junk character or non ASCII character in my XML. Later I found the solution by getting content in UTF-8 format. Below is the code change.


InputStream is= new FileInputStream("D:\\data\\response.xml");
Reader readerobj = new InputStreamReader(is,"UTF-8");
InputSource isr = new InputSource(readerobj);
isr.setEncoding("UTF-8");
saxParser.parse(isr);


About vtm

Well done is better than Well Said!!! Web Enthusiast, Blogger, Open source contributor!!! And Web/Software Consultant for Personal and Business

Leave a comment

Your email address will not be published. Required fields are marked *

9 + 12 =