我有以下代码:
HttpClient FETCHER
HttpResponse response = FETCHER.execute(host, httpMethod);
我试图将其内容读取为这样的字符串:
HttpEntity entity = response.getEntity();
InputStream st = entity.getContent();
StringWriter writer = new StringWriter();
IOUtils.copy(st, writer);
String content = writer.toString();
问题是,当我获取http://www.google.co.in/页面时,传输编码被分块,我只得到第一个块。它直到第一个“”。
如何一次性获取所有块,以便我可以转储完整的输出并对其进行处理?
答案 0 :(得分:1)
你不应该使用writeTo吗? 文档说:
将实体内容写入 输出流。