The zlib docs specify that one can pass a negative windowBits argument to the deflateInit2() function:
windowBitscan also be –8..–15 for raw deflate. In this case,-windowBitsdetermines the window size.deflate()will then generate rawdeflatedata with no zlib header or trailer, and will not compute an adler32 check value.
I've used this in my C code, and in Java am able to inflate bytes thus compressed by passing true for the nowrap parameter to the Inflater constructor.
However, passing true for the nowrap parameter to the Deflater does not yield a raw deflate. It returns 20 more bytes than I get with my C implementation, which sure sounds like a header and checksum. (Passing false for nowrap yields an even longer byte array.)
I've scanned through the Deflater docs but have not found a way to specify window bits or that I want a raw deflate. Is it possible with this library? Or would I need to use some other implementation to get a raw deflate in Java?
Deflater produces zlib-wrapped data (RFC 1950). Deflater(level, true) produces raw deflate data (RFC 1951).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With