public final class ZLib
This class implements stream compression with the ZLib library.
zlib is designed to be a free, general-purpose, legally unencumbered - that is, not covered by any
patents -- lossless data-compression library for use on virtually any computer hardware and operating system. The
zlib data format is itself portable across platforms.
Deflates the given stream 'in' with the specified compression level, writing the result to the given stream 'out'.
Compressed data will be generated in ZLIB format using the default strategy and the default compression level.
public static int deflate(Stream in,
Deflates the given stream 'in' using the specified strategy and compression level, writing the result to the given
stream 'out'. If 'nowrap' is true then the ZLIB header and checksum fields will not be used in order to support
the compression format used in both GZIP and PKZIP.
in - Stream to be deflated
out - Deflated stream.
compressionLevel - compression level, which must be between 0 and 9, or -1 for the default compression level
strategy - the compression strategy
noWrap - if true then use GZIP compatible compression
Attempts to read the number of bytes specified by 'sizeIn' from the the given stream 'in', inflating and writing
to the given stream 'out'. If 'sizeIn' is -1, it will attempt to fully read the stream. If the parameter 'noWrap'
is true then the ZLIB header and checksum fields will not be used. This provides compatibility with the
compression format used by both GZIP and PKZIP.
Note: When using the 'noWrap' option it is also necessary to provide an extra "dummy" byte as input. This is
required by the ZLIB native library in order to support certain optimizations.
in - Deflated input stream
out - Inflated output stream
sizeIn - How many bytes to read, or -1 to read until in's end
noWrap - if true then support GZIP compatible compression