All Packages Class Hierarchy This Package Previous Next Index

Class java.util.zip.Deflater

java.lang.Object | +----java.util.zip.Deflater
public class Deflater
extends Object
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).

See Also:
Inflater

Variable Index

 o BEST_COMPRESSION
Compression level for best compression.
 o BEST_SPEED
Compression level for fastest compression.
 o DEFAULT_COMPRESSION
Default compression level.
 o DEFAULT_STRATEGY
Default compression strategy.
 o DEFLATED
Compression method for the deflate algorithm (the only one currently supported).
 o FILTERED
Compression strategy best used for data consisting mostly of small values with a somewhat random distribution.
 o HUFFMAN_ONLY
Compression strategy for Huffman coding only.
 o NO_COMPRESSION
Compression level for no compression.

Constructor Index

 o Deflater()
Creates a new compressor with the default compression level.
 o Deflater(int)
Creates a new compressor using the specified compression level.
 o Deflater(int, boolean)
Creates a new compressor using the specified compression level.

Method Index

 o deflate(byte[])
Fills specified buffer with compressed data.
 o deflate(byte[], int, int)
Fills specified buffer with compressed data.
 o end()
Discards unprocessed input and frees internal data.
 o finalize()
Frees the compressor when garbage is collected.
 o finish()
When called, indicates that compression should end with the current contents of the input buffer.
 o finished()
Returns true if the end of the compressed data output stream has been reached.
 o getAdler()
Returns the ADLER-32 value of the uncompressed data.
 o getTotalIn()
Returns the total number of bytes input so far.
 o getTotalOut()
Returns the total number of bytes output so far.
 o needsInput()
Returns true if the input data buffer is empty and setInput() should be called in order to provide more input.
 o reset()
Resets deflater so that a new set of input data can be processed.
 o setDictionary(byte[])
Sets preset dictionary for compression.
 o setDictionary(byte[], int, int)
Sets preset dictionary for compression.
 o setInput(byte[])
Sets input data for compression.
 o setInput(byte[], int, int)
Sets input data for compression.
 o setLevel(int)
Sets the current compression level to the specified value.
 o setStrategy(int)
Sets the compression strategy to the specified value.

Variables

 o DEFLATED public static final int DEFLATED
Compression method for the deflate algorithm (the only one currently supported).

 o NO_COMPRESSION public static final int NO_COMPRESSION
Compression level for no compression.

 o BEST_SPEED public static final int BEST_SPEED
Compression level for fastest compression.

 o BEST_COMPRESSION public static final int BEST_COMPRESSION
Compression level for best compression.

 o DEFAULT_COMPRESSION public static final int DEFAULT_COMPRESSION
Default compression level.

 o 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.

 o HUFFMAN_ONLY public static final int HUFFMAN_ONLY
Compression strategy for Huffman coding only.

 o DEFAULT_STRATEGY public static final int DEFAULT_STRATEGY
Default compression strategy.

Constructors

 o 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
 o 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)
 o Deflater public Deflater()
Creates a new compressor with the default compression level. Compressed data will be generated in ZLIB format.

Methods

 o 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.

Parameters:
b - the input data bytes
off - the start offset of the data
len - the length of the data
See Also:
needsInput
 o setInput public void setInput(byte b[])
Sets input data for compression. This should be called whenever needsInput() returns true indicating that more input data is required.

Parameters:
b - the input data bytes
See Also:
needsInput
 o 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.

Parameters:
b - the dictionary data bytes
off - the start offset of the data
len - the length of the data
See Also:
inflate, getAdler
 o setDictionary public void setDictionary(byte b[])
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.

Parameters:
b - the dictionary data bytes
See Also:
inflate, getAdler
 o setStrategy public synchronized void setStrategy(int strategy)
Sets the compression strategy to the specified value.

Parameters:
strategy - the new compression strategy
Throws: IllegalArgumentException
if the compression strategy is invalid
 o setLevel public synchronized void setLevel(int Level)
Sets the current compression level to the specified value.

Parameters:
level - the new compression level (0-9)
Throws: IllegalArgumentException
if the compression level is invalid
 o needsInput public boolean needsInput()
Returns true if the input data buffer is empty and setInput() should be called in order to provide more input.

 o finish public synchronized void finish()
When called, indicates that compression should end with the current contents of the input buffer.

 o finished public synchronized boolean finished()
Returns true if the end of the compressed data output stream has been reached.

 o 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
Returns:
the actual number of bytes of compressed data
 o deflate public int deflate(byte b[])
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
 o getAdler public native synchronized int getAdler()
Returns the ADLER-32 value of the uncompressed data.

 o getTotalIn public native synchronized int getTotalIn()
Returns the total number of bytes input so far.

 o getTotalOut public native synchronized int getTotalOut()
Returns the total number of bytes output so far.

 o reset public native synchronized void reset()
Resets deflater so that a new set of input data can be processed. Keeps current compression level and strategy settings.

 o end public native synchronized void end()
Discards unprocessed input and frees internal data.

 o finalize protected void finalize()
Frees the compressor when garbage is collected.

Overrides:
finalize in class Object

All Packages Class Hierarchy This Package Previous Next Index
Submit a bug or feature