XML parsers sometimes fail parsing large XML files on Android
I'm parsing large XML files (~1-2M) in my application. Occasionally parser fails when parsing some files.
Symptoms:
- Sometimes the same file is parsed successfully, sometimes - not.
- If parsing of a file fails it will take some time before the file can be parsed successfully again.
- I use 2 types of XML parsers: SAX (XMLReader) and Pull (XMLPullParser), both of them fail near the same place in the file.
- I use FileInputStream as the input source for parsers.
- The same file compressed via zip and then opened via ZipFile.getInpu开发者_开发知识库tStream (almost) always parsed successfully.
- I tryed to wrap FileInputStream with BufferedInputStream - nothing changed.
- If parsing fails the next attempts to parse the file fail in the same place in the file.
I believe there can be two causes:
- FileInputStream works incorrectly.
- XML parsers work incorrectly with FileInputStream's (I heard both parsers implemented on the same base in Android).
Please help to fix the problem or advise a workaround.
Thanks.
This is the case if you experience the problem only sometimes. If the problem occurs each time you run the application the problem could be with XML.
In my case I believe it is device (I have Samsung I5700) or sdcard issue, because none of my application's users report same problem.
I'm going to reformat sdcard with android or try/buy another one.
精彩评论