Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Reply
New Developer
mobilekpi
Posts: 8
Registered: ‎08-18-2009
My Device: Not Specified
Accepted Solution

ZLibInputStream compression compatibility and issues

I am wondering if anyone have experience using ZLibInputStream successfully. We are developing a client / server application and the server compresses the content sent to the client using gzip, which includes the header and trailer. When I download the compressed content through a web browser it opens correctly, and also gunzip opens it correctly. However, when I try to inflate the content through the ZLibInputStream I get an error: "incorrect header check". I also tried using noWrap=true (although according to the documentation noWrap should be false if the gzip header is included), I get a "invalid block type" error. 

 

I initialize the class the following way (inbuff contains the compressed buffer received from the server)

 

 

ByteArrayInputStream instream  = new ByteArrayInputStream(inbuff);

ZLibInputStream zin = new ZLibInputStream(instream, false);

The exception is thrown at the following read call:

 

zin.read(buff, 0, n);

 

I am also wondering if anybody knows how to determine the size of the inflated buffer.

 

Thanks!

 

 

 

 

 

Developer
ydaraishy
Posts: 562
Registered: ‎09-30-2009
My Device: Not Specified

Re: ZLibInputStream compression compatibility and issues

A gzip file is not the same as a Zlib encoded stream. Try using the GzipInputStream (or whatever it's called).

New Developer
mobilekpi
Posts: 8
Registered: ‎08-18-2009
My Device: Not Specified

Re: ZLibInputStream compression compatibility and issues

Thank you. That solved the problem.