This class provides support for general purpose decompression using
the popular ZLIB compression library. The ZLIB compression library
was initially developed as part of the PNG graphics standard and is
not protected by patents. It is fully described in RFCs 1950, 1951,
and 1952, which can be found at
ftp://ds.internic.net/rfc in the files rfc1950.txt (zlib format),
rfc1951.txt (deflate format) and rfc1952.txt (gzip format).
Sets the compression strategy to the specified value.
DEFLATED
public static final int DEFLATED
Compression method for the deflate algorithm (the only one currently
supported).
NO_COMPRESSION
public static final int NO_COMPRESSION
Compression level for no compression.
BEST_SPEED
public static final int BEST_SPEED
Compression level for fastest compression.
BEST_COMPRESSION
public static final int BEST_COMPRESSION
Compression level for best compression.
DEFAULT_COMPRESSION
public static final int DEFAULT_COMPRESSION
Default compression level.
FILTERED
public static final int FILTERED
Compression strategy best used for data consisting mostly of small
values with a somewhat random distribution. Forces more Huffman coding
and less string matching.
HUFFMAN_ONLY
public static final int HUFFMAN_ONLY
Compression strategy for Huffman coding only.
DEFAULT_STRATEGY
public static final int DEFAULT_STRATEGY
Default compression strategy.
Deflater
public Deflater(int level,
boolean nowrap)
Creates a new compressor using the specified compression level.
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.
Parameters:
level - the compression level (0-9)
nowrap - if true then use GZIP compatible compression
Deflater
public Deflater(int level)
Creates a new compressor using the specified compression level.
Compressed data will be generated in ZLIB format.
Parameters:
level - the compression level (0-9)
Deflater
public Deflater()
Creates a new compressor with the default compression level.
Compressed data will be generated in ZLIB format.
setInput
public synchronized void setInput(byte b[],
int off,
int len)
Sets input data for compression. This should be called whenever
needsInput() returns true indicating that more input data is required.
setDictionary
public native synchronized void setDictionary(byte b[],
int off,
int len)
Sets preset dictionary for compression. A preset dictionary is used
when the history buffer can be predetermined. When the data is later
uncompressed with Inflater.inflate(), Inflater.getAdler() can be called
in order to get the Adler-32 value of the dictionary required for
decompression.
Sets preset dictionary for compression. A preset dictionary is used
when the history buffer can be predetermined. When the data is later
uncompressed with Inflater.inflate(), Inflater.getAdler() can be called
in order to get the Adler-32 value of the dictionary required for
decompression.
Returns true if the end of the compressed data output stream has
been reached.
deflate
public native synchronized int deflate(byte b[],
int off,
int len)
Fills specified buffer with compressed data. Returns actual number
of bytes of compressed data. A return value of 0 indicates that
needsInput() should be called in order to determine if more input
data is required.
Parameters:
b - the buffer for the compressed data
off - the start offset of the data
len - the maximum number of bytes of compressed data
Fills specified buffer with compressed data. Returns actual number
of bytes of compressed data. A return value of 0 indicates that
needsInput() should be called in order to determine if more input
data is required.
Parameters:
b - the buffer for the compressed data
Returns:
the actual number of bytes of compressed data
getAdler
public native synchronized int getAdler()
Returns the ADLER-32 value of the uncompressed data.
getTotalIn
public native synchronized int getTotalIn()
Returns the total number of bytes input so far.
getTotalOut
public native synchronized int getTotalOut()