巨大的HttpPost响应:JSON

时间:2012-06-26 14:32:43

标签: android json http bufferedreader

我正在发送HttpPost请求并以JSON格式获取响应。但是,由于响应如此巨大,我只能收到一小部分响应,而不是我在浏览器中看到的响应。我的代码如下:

StringBuilder builder = new StringBuilder();
HttpPost httpPost = new HttpPost(uri);
HttpResponse response = client.execute(httpPost);
HttpEntity entity = response.getEntity();
InputStream content = entity.getContent();
BufferedReader reader = new BufferedReader(new InputStreamReader(content));
String line;
while ((line = reader.readLine()) != null) {
    builder.append(line);
}

默认缓冲区大小为8192个字符。我只是尝试提供更多价值,但这并不重要。所以,对此有任何建议......

2 个答案:

答案 0 :(得分:2)

我认为+ Che Jami正在OP中。

Manjunath,logcat一次只能输出1024个字符。您是否尝试一次输出1024个字符串的字符串构建器?读完之后你检查了字符串的长度吗?

答案 1 :(得分:-1)

在您的回复中仅发送完整回复的块(批次),并且在您的回复未完成时使用轮询。

相关问题