java.util.zip
public class Deflater extends Object
Field Summary | |
---|---|
static int | BEST_COMPRESSION
The best and slowest compression level. |
static int | BEST_SPEED
The worst but fastest compression level. |
static int | DEFAULT_COMPRESSION
The default compression level. |
static int | DEFAULT_STRATEGY
The default strategy. |
static int | DEFLATED
The compression method. |
static int | FILTERED
This strategy will only allow longer string repetitions. |
static int | HUFFMAN_ONLY
This strategy will not look for string repetitions at all. |
static int | NO_COMPRESSION
This level won't compress at all but output uncompressed blocks. |
Constructor Summary | |
---|---|
Deflater()
Creates a new deflater with default compression level. | |
Deflater(int lvl)
Creates a new deflater with given compression level. | |
Deflater(int lvl, boolean noHeader)
Creates a new deflater with given compression level. |
Method Summary | |
---|---|
int | deflate(byte[] output)
Deflates the current input block to the given array. |
int | deflate(byte[] output, int off, int len)
Deflates the current input block to the given array. |
void | end()
Frees all objects allocated by the compressor. |
protected void | finalize()
Finalizes this object. |
void | finish()
Finishes the deflater with the current input block. |
boolean | finished()
Returns true iff the stream was finished and no more output bytes
are available. |
int | getAdler()
Gets the current adler checksum of the data that was processed so
far. |
long | getBytesRead()
Gets the number of input bytes processed so far. |
long | getBytesWritten()
Gets the number of output bytes so far. |
boolean | needsInput()
Returns true, if the input buffer is empty.
|
void | reset()
Resets the deflater. |
void | setDictionary(byte[] dict)
Sets the dictionary which should be used in the deflate process.
|
void | setDictionary(byte[] buf, int off, int len)
Sets the dictionary which should be used in the deflate process.
|
void | setInput(byte[] input)
Sets the data which should be compressed next. |
void | setInput(byte[] input, int off, int len)
Sets the data which should be compressed next. |
void | setLevel(int lvl)
Sets the compression level. |
void | setStrategy(int stgy)
Sets the compression strategy. |
Parameters: lvl the compression level, a value between NO_COMPRESSION and BEST_COMPRESSION, or DEFAULT_COMPRESSION.
Throws: IllegalArgumentException if lvl is out of range.
Parameters: lvl the compression level, a value between NO_COMPRESSION and BEST_COMPRESSION. nowrap true, iff we should suppress the deflate header at the beginning and the adler checksum at the end of the output. This is useful for the GZIP format.
Throws: IllegalArgumentException if lvl is out of range.
Parameters: output the buffer where to write the compressed data.
Parameters: output the buffer where to write the compressed data. offset the offset into the output array. length the maximum number of bytes that may be written.
Throws: IllegalStateException if end() was called. IndexOutOfBoundsException if offset and/or length don't match the array length.
Deprecated: Just clear all references to deflater instead.
Frees all objects allocated by the compressor. There's no reason to call this, since you can just rely on garbage collection. Exists only for compatibility against Sun's JDK, where the compressor allocates native memory. If you call any method (even reset) afterwards the behaviour is undefined.Since: 1.5
Since: 1.5
setDictionary(dict, 0,
dict.length)
.Parameters: dict the dictionary.
Throws: IllegalStateException if setInput () or deflate () were already called or another dictionary was already set.
Parameters: dict the dictionary. offset an offset into the dictionary. length the length of the dictionary.
Throws: IllegalStateException if setInput () or deflate () were already called or another dictionary was already set.
setInput(input, 0, input.length)
.Parameters: input the buffer containing the input data.
Throws: IllegalStateException if the buffer was finished() or ended().
Parameters: input the buffer containing the input data. off the start of the data. len the length of the data.
Throws: IllegalStateException if the buffer was finished() or ended() or if previous input is still pending.
Parameters: lvl the new compression level.
Parameters: stgy the new compression strategy.