Android的 - 解析使用SAX解析器大文件大文件、Android、SAX

2023-09-06 05:44:15 作者:独步杀戮

我试图解析XML数据从web服务使用SAX解析器来了,当我尝试分析数据(大小:7.4MB),使用URL,它工作正常,但是当我从URL复制XML数据并把XML文件:在原始文件夹(大小7.4MB),解析失败。

当放置在原始文件夹中的文件的大小减小到1.95MB,它工作正常。我曾尝试洗牌标签,以检查是否有与数据的任何问题,我还没有发现any.It只要大小不超过1.95MB工作正常。有没有大小限制,而在Android的分析从原文件夹中的数据?如果是有什么限制?或如何使用SAX解析器解析大文件?

任何指针将真正帮助我。预先感谢您的时间和提供的任何帮助。

问候,拉梅什

  02-14 17:35:35.651:DEBUG /资产(11035):数据超过UNCOM preSS_DATA_MAX(2138421 VS 2097152)02-14 17:35:35.651:WARN / dalvikvm(11035):主题ID = 9:螺纹未捕获的异常(组= 0x4001d7d0)退出02-14 17:35:35.659:ERROR / AndroidRuntime(11035):致命异常:螺纹1302-14 17:35:35.659:ERROR / AndroidRuntime(11035):java.lang.AssertionError:java.io.IOException异常02-14 17:35:35.659:ERROR / AndroidRuntime(11035):在android.util.Xml.parse(Xml.java:89) 

code

  {尝试    的System.out.println(1);    //Xml.parse((url.openConnection()的getInputStream()),Encoding.UTF_8,的DataHandler)。    Xml.parse(getResources()openRawResource(R.raw.sample),Encoding.UTF_8,DataHandler的);    的System.out.println(2);    //xr.parse(new的InputSource)(getAssets()开(sample.xml中)。);}赶上(例外五){    的System.out.println(拉梅什+XML解析异常:+ E);} 
Android学习笔记 sax解析xml文件

错误

  Android的DEBUG /资产(11035):数据超过UNCOM preSS_DATA_MAX(2138421 VS 2097152)WARN / dalvikvm(11035):主题ID = 9:螺纹未捕获的异常退出(组= 0x4001d7d0)ERROR / AndroidRuntime(11035):致命异常:螺纹13ERROR / AndroidRuntime(11035):java.lang.AssertionError:java.io.IOException异常ERROR / AndroidRuntime(11035):在android.util.Xml.parse(Xml.java:89)ERROR / AndroidRuntime(11035):在com.infosys.gss.ui.Login $ 2 $ 1.run(Login.java:431)ERROR / AndroidRuntime(11035):由:java.io.IOException异常 

解决方案

感谢您的意见。我发现这个解决方法,感谢布赖恩谁张贴了这里的解决方案http://ponystyle.com/blog/2010/03/26/dealing-with-asset-com$p$pssion-in-android-应用/'。此链接帮助我很多东西。

I am trying to parse the xml data coming from webservice using SAX parser, when i try to parse the data(size:7.4MB) using URL, it works fine but when I copy the xml data from the URL and place the xml file(size:7.4MB) in the raw folder, the parsing fails.

When the size of file placed in raw folder is reduced to 1.95MB, it works fine. I have tried shuffling the tags to check if there are any issues with the data, I haven't found any.It works fine as long as the size doesn't exceed 1.95MB. Is there any size limit while parsing the data from raw folder in android? if yes what is the limit? or How to parse the large files using SAX parser?

Any pointers will really help me. Thanks in advance for your time and any help offered.

Regards, Ramesh

02-14 17:35:35.651: DEBUG/asset(11035): Data exceeds UNCOMPRESS_DATA_MAX (2138421 vs 2097152) 
02-14 17:35:35.651: WARN/dalvikvm(11035): threadid=9: thread exiting with uncaught exception (group=0x4001d7d0) 
02-14 17:35:35.659: ERROR/AndroidRuntime(11035): FATAL EXCEPTION: Thread-13 
02-14 17:35:35.659: ERROR/AndroidRuntime(11035): java.lang.AssertionError: java.io.IOException 
02-14 17:35:35.659: ERROR/AndroidRuntime(11035): at android.util.Xml.parse(Xml.java:89) 

code

try { 
    System.out.println("1"); 
    //Xml.parse((url.openConnection().getInputStream()), Encoding.UTF_8, datahandler); 
    Xml.parse(getResources().openRawResource(R.raw.sample), Encoding.UTF_8, datahandler); 
    System.out.println("2"); 
    //xr.parse(new InputSource(getAssets().open("sample.xml")));
}catch(Exception e){ 
    System.out.println("Ramesh"+"XML Parsing exception:"+e);
}

error

Android DEBUG/asset(11035): Data exceeds UNCOMPRESS_DATA_MAX (2138421 vs 2097152) 
WARN/dalvikvm(11035): threadid=9: thread exiting with uncaught exception (group=0x4001d7d0) 
ERROR/AndroidRuntime(11035): FATAL EXCEPTION: Thread-13 
ERROR/AndroidRuntime(11035): java.lang.AssertionError: java.io.IOException 
ERROR/AndroidRuntime(11035): at android.util.Xml.parse(Xml.java:89) 
ERROR/AndroidRuntime(11035): at com.infosys.gss.ui.Login$2$1.run(Login.java:431) 
ERROR/AndroidRuntime(11035): Caused by: java.io.IOException

解决方案

Thanks for your comments. I have found a workaround for this, thanks to Brian who has posted the solution here 'http://ponystyle.com/blog/2010/03/26/dealing-with-asset-compression-in-android-apps/'. This link helped me lot.