| java.lang.Object | |
| ↳ | java.util.zip.Deflater |
The Deflater class is used to compress bytes using the DEFLATE compression algorithm. Deflation is performed by the ZLIB compression library.
| Constants | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
| int | BEST_COMPRESSION | ||||||||||
| int | BEST_SPEED | ||||||||||
| int | DEFAULT_COMPRESSION | ||||||||||
| int | DEFAULT_STRATEGY | ||||||||||
| int | DEFLATED | ||||||||||
| int | FILTERED | ||||||||||
| int | HUFFMAN_ONLY | ||||||||||
| int | NO_COMPRESSION | ||||||||||
| Public Constructors | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
Constructs a new Deflater instance with default compression level and
strategy.
| |||||||||||
Constructs a new Deflater instance with compression level level and
default compression strategy.
| |||||||||||
Constructs a new Deflater instance with compression level level and
default compression strategy.
| |||||||||||
| Public Methods | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
Deflates data into the supplied buffer
| |||||||||||
Deflates data into the supplied buffer using the region from off to
nbytes - 1.
| |||||||||||
Frees all resources held onto by this Deflater.
| |||||||||||
Indicates to the Deflater that all uncompressed input has been provided
to it.
| |||||||||||
Returns whether or not all provided data has been successfully
compressed.
| |||||||||||
Returns the Adler32 checksum of uncompressed data currently read.
| |||||||||||
Returns a long int of total number of bytes read by the Deflater.
| |||||||||||
Returns a long int of total number of bytes of read by the Deflater.
| |||||||||||
Returns the total number of bytes of input consumed by the deflater.
| |||||||||||
Returns the total number of compressed bytes output by this Deflater.
| |||||||||||
Indicates whether or not all bytes of uncompressed input have been
consumed by the Deflater.
| |||||||||||
Resets the
Deflater to accept new input without affecting
any previously made settings for the compression strategy or level. | |||||||||||
Sets the dictionary to be used for compression by this Deflater.
| |||||||||||
Sets the input buffer the Deflater will use to extract uncompressed bytes
for later compression.
| |||||||||||
Sets the input buffer the Deflater will use to extract uncompressed bytes
for later compression.
| |||||||||||
Sets the compression level to be used when compressing data.
| |||||||||||
Sets the compression strategy to be used.
| |||||||||||
| Protected Methods | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
Called by the virtual machine when there are no longer any (non-weak)
references to the receiver.
| |||||||||||
|
[Expand]
Inherited Methods | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
From class java.lang.Object
| |||||||||||
Constructs a new Deflater instance with default compression level and strategy.
Constructs a new Deflater instance with compression level level and default compression strategy. THe compression level provided must be between 0 and 9.
| level | the compression level to use |
|---|
Constructs a new Deflater instance with compression level level and default compression strategy. If the noHeader parameter is specified then no ZLIB header will be written as part of the compressed output. The compression level specified must be between 0 and 9.
| level | the compression level to use |
|---|---|
| noHeader | if true do not write the ZLIB header |
Deflates data into the supplied buffer
| buf | buffer to store compressed data |
|---|
Deflates data into the supplied buffer using the region from off to nbytes - 1.
| buf | buffer to store compressed data |
|---|---|
| off | offset inf buf to start storing data |
| nbytes | number of bytes of compressed data to store in buf |
Frees all resources held onto by this Deflater. Any unused input or output is discarded. This is also called from the finalize method.
Indicates to the Deflater that all uncompressed input has been provided to it.
Returns whether or not all provided data has been successfully compressed.
Returns the Adler32 checksum of uncompressed data currently read. If a preset dictionary is used getAdler() will return the Adler32 checksum of the dictionary used.
Returns a long int of total number of bytes read by the Deflater. This method performs the same as getTotalIn except it returns a long value instead of an integer
Returns a long int of total number of bytes of read by the Deflater. This method performs the same as getTotalOut except it returns a long value instead of an integer
Returns the total number of bytes of input consumed by the deflater.
Returns the total number of compressed bytes output by this Deflater.
Indicates whether or not all bytes of uncompressed input have been consumed by the Deflater. If needsInput() returns true setInput() must be called before deflation can continue. If all bytes of uncompressed data have been provided to the Deflater finish() must be called to ensure the compressed data is output.
Resets the Deflater to accept new input without affecting
any previously made settings for the compression strategy or level. This
operation must be called after finished() returns
true if the Deflater is to be reused.
Sets the dictionary to be used for compression by this Deflater. setDictionary() can only be called if this Deflater supports the writing of ZLIB headers. This is the default behaviour but can be overridden using Deflater(int, boolean).
Sets the input buffer the Deflater will use to extract uncompressed bytes for later compression. Input will be taken from the buffer region starting at off and ending at nbytes - 1.
Sets the input buffer the Deflater will use to extract uncompressed bytes for later compression.
Sets the compression level to be used when compressing data. The compression level must be a value between 0 and 9. This value must be set prior to calling setInput().
| level | compression level to use |
|---|
| IllegalArgumentException | If the compression level is invalid. |
|---|
Sets the compression strategy to be used. The strategy must be one of FILTERED, HUFFMAN_ONLY or DEFAULT_STRATEGY.This value must be set prior to calling setInput().
| strategy | compression strategy to use |
|---|
| IllegalArgumentException | If the strategy specified is not one of FILTERED, HUFFMAN_ONLY or DEFAULT_STRATEGY. |
|---|
Called by the virtual machine when there are no longer any (non-weak) references to the receiver. Subclasses can use this facility to guarantee that any associated resources are cleaned up before the receiver is garbage collected. Uncaught exceptions which are thrown during the running of the method cause it to terminate immediately, but are otherwise ignored.
Note: The virtual machine assumes that the implementation in class Object is empty.