I am trying to create a gzip file using jzlib which is an open source. The Java GZIPOutputStream is a bit problemtic, the CPU got higher and never released.
The problem with the JZlib that the file cannot be open by winrar, it seems like missing header. Any idea how to solve it?
JZlib does not support the Gzip data format (RFC 1952), only zlib (RFC 1950) and plain deflate (RFC 1951).
These formats differ only by the header and a checksum at the end:
Thus you can write your own wrapper around jzlib's deflate compressing stream (using nowrap=true to avoid the zlib header), adding your metadata and the CRC32 checksum. Or you take a look if someone else already did this. (Looks like bestsss' answer does about this.)
This is skimmed version of the class; Hopefully it can serve.
This version still retains proper flush() implementation.
The original version has optimizations for in-mem process (hopefully it still works after cutting some part). The source contains CRC32 from Apache and proper notice to the License.
Since JZlib 1.1.0, it has supported gzip file format. Try com.jcraft.jzlib.GZIPOutputStream class