Difference between Deflater and GZip compression

compression, java

Solution

`Deflater` produces zlib-wrapped deflate compressed data, unless `nowrap` is true, in which case it produces raw (unwrapped) deflate compressed data.

`GZIPOutputStream` produces gzip-wrapped deflate data.

deflate is a compressed data format defined in RFC 1951.

zlib is a two-byte header and four-byte trailer that provides compact identification of the stream and integrity checking on the uncompressed data. zlib is described in RFC 1950.

gzip is a 10+ byte header and 8-byte trailer that provides metadata and integrity checking, where the metadata can include a file name, modification date, originating operating system, comment, and extra data. gzip is described in RFC 1952.

There is no difference with respect to performance, other than a few bytes difference in the header and trailer.

Problem

I am currently using `java.util.zip.Deflater` to compress. Also `java.util.zip.GZIPOutputStream` can be used for compression. Here I focus on basically byte array compression. Can any one let me know the difference between these Deflater and GZIPOutputStream. (performancewise..).

Original source