我正在启动几个线程来从网络上获取图像。问题是我随机在一两个请求中得到 java.io.EOFException 。这是我正在使用的代码,异常发生在 decodeStream 调用中:
InputStream inputStream = (InputStream) new URL(slot.mUrl).getContent();
mBitmap = BitmapFactory.decodeStream(inputStream);
inputStream.close();
这是堆栈信息:
java.io.EOFException
at libcore.io.Streams.readAsciiLine(Streams.java:203)
at libcore.net.http.HttpEngine.readResponseHeaders(HttpEngine.java:560)
at libcore.net.http.HttpEngine.readResponse(HttpEngine.java:813)
at libcore.net.http.HttpURLConnectionImpl.getResponse(HttpURLConnectionImpl.java:274)
at libcore.net.http.HttpURLConnectionImpl.getHeaderField(HttpURLConnectionImpl.java:130)
at java.net.URLConnection.getContentType(URLConnection.java:326)
at java.net.URLConnection.getContent(URLConnection.java:193)
at java.net.URL.getContent(URL.java:447)
知道有什么问题吗?
谢谢,雅科邦