2

我在 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();

它看起来运行良好,但有时我得到 IOException - 预期为十六进制块大小,但......发生在:

line = reader.readLine();

这是如何发生的?如何解决?更改缓冲阅读器大小有帮助吗?谢谢

4

1 回答 1

1

见源 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);
}

看起来数据中有一些不正确的地方。

于 2012-05-08T13:05:24.580 回答