ArrayIndexOutOfBoundsException异常在Android的KXmlParser [英] ArrayIndexOutOfBoundsException in android's KXmlParser

查看:2537
本文介绍了ArrayIndexOutOfBoundsException异常在Android的KXmlParser的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Android上做定期的XML解析,极少我得到这个例外,只有在特定的手机。一直没能得到这个问题的根源。没有任何人有一个想法是什么可能会导致什么呢?

  java.lang.ArrayIndexOutOfBoundsException:src.length = 8192 srcPos = 1 dst.length = 8192 dstPos = 0长度= -1
    在java.lang.System.arraycopy(本机方法)
    在org.kxml2.io.KXmlParser.fillBuffer(KXmlParser.java:1489)
    在org.kxml2.io.KXmlParser.skip(KXmlParser.java:1574)
    在org.kxml2.io.KXmlParser.parseStartTag(KXmlParser.java:1049)
    在org.kxml2.io.KXmlParser.next(KXmlParser.java:369)
    在org.kxml2.io.KXmlParser.next(KXmlParser.java:310)


解决方案

我有一个类似的异常。在我的情况下,XML已经下载并保存到SD。当我打开文件,我看到它切出中等句,因为它是。它看起来像有过在下载文件中的错误。删除文件和重新下载固定问题在这种情况下,但以prevent将来的相同类型的问题,我检查ArrayIndexOutOfBoundsException异常读取XML时,并假定文件损坏时,它捕获之一。

这显然只是一个创可贴解决一个定义模糊问题的时刻。如果我的数字多出,我会更新我的答案。

I am doing regular XML parsing on android, and very rarely I get this exception and only on particular phones. Haven't been able to get to the root of this issue. Does anybody have an idea what might be causing this?

    java.lang.ArrayIndexOutOfBoundsException: src.length=8192 srcPos=1 dst.length=8192 dstPos=0 length=-1
    at java.lang.System.arraycopy(Native Method)
    at org.kxml2.io.KXmlParser.fillBuffer(KXmlParser.java:1489)
    at org.kxml2.io.KXmlParser.skip(KXmlParser.java:1574)
    at org.kxml2.io.KXmlParser.parseStartTag(KXmlParser.java:1049)
    at org.kxml2.io.KXmlParser.next(KXmlParser.java:369)
    at org.kxml2.io.KXmlParser.next(KXmlParser.java:310)

解决方案

I have a similar exception. In my case, the xml had been downloaded and saved to the SD. When I opened the file, I saw that it cut out "mid-sentence", as it were. It looked like there had been an error in downloading the file. Deleting the file and re-downloading fixed the issue in this instance, but to prevent future issues of the same type, I check for ArrayIndexOutOfBoundsException when reading an xml, and assume the file is corrupt when it catches one.

It's obviously just a bandaid solution to a vaguely defined problem at the moment. If I figure more out, I'll update my answer.

这篇关于ArrayIndexOutOfBoundsException异常在Android的KXmlParser的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆