我在 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 大小有帮助吗? 谢谢
最佳答案
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/