2010-05-18 57 views
4

数据我有以下代码:阅读分块从HttpEntity

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/页,传输编码被分块,我只得到第一个块。它提取到第一个“”。

我如何获得所有的块,所以我可以转储完整的输出并对它做一些处理?

回答

1

不应该使用writeTo? 文档说:

将实体内容写入 输出流。