hc-httpclient-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jeroen ter Voorde <j.tervoo...@home.nl>
Subject Re: response body as stream
Date Tue, 24 Jan 2006 13:03:32 GMT
Hi,

You should use a FileOutputStream and directly stream the response body 
stream instead of using a Reader and Writer (which performs
character decoding using the supplied charset and therefore corrupts 
your file).

Jeroen

Bogdan Mihaila wrote:

>Hello!
>   
>  I try to download ZIP files with httpclient, and I want to get the response as stream,
not as byte[]... It downloades the files (the sizes are Ok), but when I open the archives
It gives me: "error in packed file" and "invalid bit length repeat". 
>   
>  I use the following code:
>   
>            Reader reader = new InputStreamReader(
>                  method.getResponseBodyAsStream(), method.getResponseCharSet()); 
>   
>            //  I use the Commons IO package
>   
>                   BufferedWriter out = new BufferedWriter(new FileWriter("...."));
>                 out.write(IOUtils.toString(reader));
>                 out.close();
>   
>  What can be the problem?
>   
>  Thanks in advance
>   
>
>		
>---------------------------------
> Yahoo! Autos. Looking for a sweet ride? Get pricing, reviews, & more on new and used
cars.
>  
>


---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: httpclient-user-help@jakarta.apache.org


Mime
View raw message