hc-httpclient-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Roland Weber <ROLWE...@de.ibm.com>
Subject Re: read and decompress gz file
Date Thu, 26 Apr 2007 07:42:34 GMT
Hello Cheok,

> I try to download a gz file, which contains a text
> file. I try to use GZIPInputStream, to unzip from the
> input stream of HttpMethod, but get a corrupted
> result.

>         while(gZipInputStream.read(data, 0,
> data.length) != -1) {
>             s.append(new String(data));
>         }

Why do you convert binary data to characters here?

>         /*
>          *However, if I download manually and use
> GZIPInputStream to extract read
>          *the file, with no HttpClient involvement, no
> problem.
>          *
>         // Transfer bytes from the compressed file to
> the output file
>         byte[] buf = new byte[1024];
>         int len;
>         while ((len = gzipInputStream.read(buf)) > 0)
> {
>         out.write(buf, 0, len);
>         }

There is no binary to character conversion here.

hope that helps,
  Roland


Mime
View raw message