views:

86

answers:

1

I have the following code:

HttpClient FETCHER
HttpResponse response = FETCHER.execute(host, httpMethod);

Im trying to read its contents to a string like this:

HttpEntity entity = response.getEntity();
InputStream st = entity.getContent();
StringWriter writer = new StringWriter();
IOUtils.copy(st, writer);
String content = writer.toString();

The problem is, when i fetch http://www.google.co.in/ page, the transfer encoding is chunked, and i get only the first chunk. It fetches till first "".

How do i get all the chunks at once so i can dump the complete output and do some processing on it ?

A: 

Shouldn't you use writeTo? The docs say:

Writes the entity content to the output stream.

dierre