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..).
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.
There is a difference in performance as GZIPOutputStream
only has one speed/compression ratio setting that is not changeable, while Deflater
has ten possible ratios, from fastest+least compressed to slowest+most compressed. Here is a good article with graphs about it.
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