Android开发时出现org.apache.harmony.xml.ExpatParser$ParseException:not well-formed错误时,我所犯的错误
来源:互联网 发布:龙的传人李青淘宝价格 编辑:程序博客网 时间:2024/06/05 05:09
这个错误搞了我一天了。原来我是做C#开发的,第一次做java,语法不是特别熟悉,另外Eclipse的开发环境也不熟悉。这个错误搞了我一整天了,搞得我都疲惫了,都准备放弃了,后来觉得,我这辈子为了一些看起来很重大的小事放弃了很多重要的人和事,觉得划不来,不能这样,更何况这是一些小事....算了,不八了。
本人的程序特点
1、服务器有个xml文件。
2、下载到本地的SD卡中
3、Android程序读取SD卡中的文件。
读取后报错说格式不对。
后来晚上,问一个朋友,他告诉我Eclipse有个DDMS可以查看SD卡的文件,我打开一看,原来真的下载到SD卡中的文件格式不正确。但服务器的格式是正确的,为什么这样呢?
后来查看了MARS老师写的FileUtils类,他的写入文件的函数利用的是byte[]方式写入,一开始,他定义的byte[] buffer = byte[4*1024],这么一个变量。
java的IO操作在读取FileInputSteam流的时候,如果读到最后了还没有填满这个buffer,则又从头开始读,一直要填满这个buffer,再给文件写入。
所以,下载到SD卡中的文件,一直是很大的,原因就是多了很多重复的数据。
后来,我把这个函数改成了一个byte一个byte的读,这样就不会出问题了,因为没有数据比一个byte还小吧。O(∩_∩)O哈哈~。
output = new FileOutputStream(file);//byte[] buffer = new byte[1024];int buffer;while((buffer = input.read()) != -1){//output.write(buffer);output.write(buffer);}output.flush();
- Android开发时出现org.apache.harmony.xml.ExpatParser$ParseException:not well-formed错误时,我所犯的错误
- 解析xml时,报错:org.apache.harmony.xml.ExpatParser$ParseException: At line 1, column 75:not well-formed
- 解析xml时,报错:org.apache.harmony.xml.ExpatParser$ParseException: At line 1, column 4:not well-formed(invaild toke)
- 解析XML时,org.apache.harmony.xml.ExpatParser$ParseException: At line 1, column 449: not well-forme
- android用SAX解析xml文件时抛出org.apache.harmony.xml.ExpatParser$ParseException异常的解决方法
- org.apache.harmony.xml.ExpatParser$ParseException mismatched tag
- 解析xml时,报错:WARN/System.err(207): org.apache.harmony.xml.ExpatParser$ParseException: At line 1,
- Android分析 Sax解析xml文件时,遇到的not well-formed错误
- org.apache.harmony.xml.ExpatParser$ParseException: At line 1, column 0: unknown encoding
- org.apache.harmony.xml.ExpatParser$ParseException: At line 1, column 0: unknown encoding
- android SAX解析xml流时报ExpatParser$ParseException错误解决方法
- 解决firefox not well-formed错误
- 关于自定义控件在布局文件中使用时提示error: Error parsing XML: not well-formed (invalid token)错误的问题
- 关于自定义控件在布局文件中使用时提示error: Error parsing XML: not well-formed (invalid token)错误的问题
- 我所犯的错误
- 布局错误error: Error parsing XML: not well-formed (invalid token)
- python 过滤xml非法字符 :not well-formed (invalid token)错误处理
- 使用android-async-http下载图片时出现org.apache.http.client.HttpResponseException: Content-Type not allowed的错误
- snmp—简单网络管理协议
- java动态代理(JDK和cglib)
- How to update or delete db
- CString 中的SpanIncluding 和SpanExcluding 用法
- MBA13, 1227 computing experience changed
- Android开发时出现org.apache.harmony.xml.ExpatParser$ParseException:not well-formed错误时,我所犯的错误
- 双语不用教 下载地址!!!
- 从N[百万]个随机整数中查找出现频率最高的所有整数
- 中断触发流程三(中断控制器)
- iOS系统的沙盒机制
- oracle %TYPE 和 %ROWTYPE
- “沙盒机制”对iOS开发的软硬件影响
- 替换jar的同名不同版本时出现奇怪的NoClassDefFoundError
- 浅谈代理服务器的作用