1

我正在尝试解析 xml,但是在 setInput 方法parser.setInput(responseStream, null);时出现错误

responseStream 值越来越好。

错误是这样的,

08-28 15:47:37.069: WARN/System.err(5429): Invalid stream or encoding: java.io.IOException: Attempted read on closed stream. (position:START_DOCUMENT null@1:1) caused by: java.io.IOException: Attempted read on closed stream.; nested exception is:
08-28 15:47:37.107: WARN/System.err(5429): java.io.IOException: Attempted read on closed stream.
08-28 15:47:37.165: WARN/System.err(5429):     at org.apache.http.conn.EofSensorInputStream.isReadAllowed(EofSensorInputStream.java:127)
08-28 15:47:37.165: WARN/System.err(5429):     at org.apache.http.conn.EofSensorInputStream.read(EofSensorInputStream.java:138)
08-28 15:47:37.186: WARN/System.err(5429):     at org.kxml2.io.KXmlParser.setInput(KXmlParser.java:1623)
08-28 15:47:37.196: WARN/System.err(5429):     atin.project.parser.Getparser.parser(Getparser.java:31)
08-28 15:47:37.246: WARN/System.err(5429):     atin.project.home.HomePgae$DataProvide.doInBackground(HomePgae.java:313)
08-28 15:47:37.279: WARN/System.err(5429):     atin.project.home.HomePgae$DataProvide.doInBackground(HomePgae.java:1)
08-28 15:47:37.279: WARN/System.err(5429):     at android.os.AsyncTask$2.call(AsyncTask.java:264)
08-28 15:47:37.286: WARN/System.err(5429):     at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:305)
08-28 15:47:37.306: WARN/System.err(5429):     at java.util.concurrent.FutureTask.run(FutureTask.java:137)
08-28 15:47:37.306: WARN/System.err(5429):     at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1076)
08-28 15:47:37.446: WARN/System.err(5429):     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:569)
08-28 15:47:37.516: WARN/System.err(5429):     at java.lang.Thread.run(Thread.java:856)

谢谢,

4

1 回答 1

1

该错误告诉您 responseStream 已经调用了 .close() 。您之前是否在代码中使用过 responseStream 或将其与任何其他调用过 .close() 的流一起包装?

于 2012-08-28T10:29:26.793 回答