org.xmlpull.v1.XmlPullParserException

我们两清 提交于 2019-12-02 08:35:58
Christian Kuetbach

The ByteArrayInputstream is empty:

only whitespace content allowed before start tag and not \u0 
(position: START_DOCUMENT seen \u0... @1:1) 

means, that a \u0 Bit was found as first char within the XML.

Ensure you have content within your byte[] and the UTF-8 don't start with a BOM.

I don't think, that the BOM is your problem here, but I often encountert regarding BOM and java.

update

You don't fill the byte[]. You have to read the file-content into the byte[]: read this: File to byte[] in Java

By the way: byte[] xmlData = new byte[(int) file.length()]; is bad code-style, becaus you will run into problems with larger XML-files. If they are larger than Integer.MAX_VALUE you will read a corrupt file.

Hari,
JiBX need characters as input. I think you have specified your encoding incorrectly. Try this code instead:

FileInputStream fis = new FileInputStream("output.xml");
InputStreamReader isr = new InputStreamReader(fis, "UTF8");
groups = (GroupsDTO) uctx.unmarshalDocument(isr);

If you must use the code you have written, I would try outputting the text to the console (System.put.println(xxx)) to make sure you are decoding the utf-8 correctly.

Don

Go to to mvn repository path and delete that folder for xml file.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!