java - Android BufferedReader ReadLine() 得到 IOException - Expected a hex chunk size ,如何解决这个问题?

标签 java android readline bufferedreader ioexception

我在 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 - 预期为十六进制 block 大小,但是...... 发生在:

line = reader.readLine();

这是如何发生的?如何解决? 更改 bufferedreader 大小有帮助吗? 谢谢

最佳答案

查看源代码 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);
}

数据中似乎有错误。

关于java - Android BufferedReader ReadLine() 得到 IOException - Expected a hex chunk size ,如何解决这个问题?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10493298/

相关文章:

java - 在 SSLHandshake 期间如何处理警告和致命警报

java - 创建具有硬件加速的表单应用程序

java - 在 Excel 中用相同的颜色填充整个工作表 - Apache POI

java - aws 凭证在 Android 示例应用程序中不起作用

java.net 套接字、readline 和行终止符(VNC 连接)

c# - 读取文件中的特定行

java - 如何在ListView Activity中实现自定义适配器

android - 使用 jpm-mobile 在 Android 上运行 Firefox 插件

android - 异步任务 : How do I access onPostExecute parameters?

delphi - 使用 TStreamReader 和 TStringList 处理非常大的文本文件