I'm trying to uncompress data that was compressed using the ZLIB library written by Jean-loup Gailly back in the 1990s. I think it is a popular library (I see a lot of programs that ship the zlib32.dll file it uses) so I hope someone will be familiar enough with it to help me. I am using the compress() function directly which from what I read uses rfc-1951 DEFLATE format.
Here is a segment of the code I am using to read some compressed data from a stream and uncompress it:
InputStream is = new ByteArrayInputStream(buf);
//GZIPInputStream gzis = new GZIPInputStream(is);
InflaterInputStream iis = new InflaterInputStream(is);
byte[] buf2 = new byte[uncompressedDataLength];
iis.read(buf2);
The iis.read(buf2) function throws an internal exception of "Data Format Error". I tried using GZIPInputStream also, but that also throws the same exception.
The "buf" variable is type byte[] and I have confirmed by debugging that it is the same as what my C program gets back from the ZLIB compress() function (the actual data comes from a server over TCP). "uncompressedDataLength" is the known size of the uncompressed data that was also provided by the C program (server).
Has anyone tried reading/writing data using this library and then reading/writing the same data on the Android using Java?
I did find a "pure Java port of ZLIB" referenced in a few places, and if I need to I can try that, but I would rather use the built-in/OS functions if possible.