[英]Android BufferedReader ReadLine() got IOException - Expected a hex chunk size , How to fix this?
I`m using BufferedReader in Android to receive http stream connection , when parse message I received use code: 我在Android中使用BufferedReader接收HTTP流连接,当解析消息时,我使用以下代码:
url = new URL(HOST_URL_PUSHMESSAGE);
urlConnection = url.openConnection();
in = (InputStream) urlConnection.getContent();
reader = new BufferedReader(new InputStreamReader(in));
line = reader.readLine();
in.close();
It looks work well but Sometime I got IOException - Expected a hex chunk size,but was.. Happened in: 它看起来不错,但有时我会出现IOException-预期为十六进制的块大小,但是发生了。
line = reader.readLine();
How does this happen & How can this be resolved? 这是如何发生的?如何解决? Does change bufferedreader size help?
更改bufferedreader的大小有帮助吗? Thanks
谢谢
See the source http://www.java2s.com/Open-Source/Android/android-core/platform-libcore/org/apache/harmony/luni/internal/net/www/protocol/http/ChunkedInputStream.java.htm The exception happens there 参见源代码http://www.java2s.com/Open-Source/Android/android-core/platform-libcore/org/apache/harmony/luni/internal/net/www/protocol/http/ChunkedInputStream.java.htm例外发生在那
try {
bytesRemainingInChunk = Integer.parseInt(chunkSizeString.trim(), 16);
} catch (NumberFormatException e) {
throw new IOException("Expected a hex chunk size, but was " + chunkSizeString);
}
Looks like something incorrect in the data. 看起来好像数据中有错误。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.