I am trying to unpack data that was compressed using the ZLIB library, written by Jean-Luir Gaylli back in the 1990s. I think this is a popular library (I see a lot of programs that send the zlib32.dll file that it uses), so I hope someone will be familiar enough with it to help me. I directly use the compress () function, which from what I'm reading uses the rfc-1951 DEFLATE format.
Here is a code snippet that I use to read compressed data from a stream and unzip 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 data format error exception. I also tried using GZIPInputStream, but this also throws the same exception.
The buf variable is a byte type [], and I confirmed with debugging that it is the same as my C program returned from the ZLIB compress () function (the actual data comes from the server via TCP). "uncompressedDataLength" is the known size of uncompressed data, which was also provided by the C program (server).
Has anyone tried to read / write data using this library and then read and write the same data on Android using Java?
I found the “pure Java ZLIB port” mentioned in several places, and if I need, I can try this, but I would prefer to use the built-in / OS functions if possible.
eselk source share