| Method from java.util.zip.Deflater Detail: |
public int deflate(byte[] b) {
return deflate(b, 0, b.length);
}
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. |
public synchronized int deflate(byte[] b,
int off,
int len) {
if (b == null) {
throw new NullPointerException();
}
if (off < 0 || len < 0 || off > b.length - len) {
throw new ArrayIndexOutOfBoundsException();
}
return deflateBytes(b, off, 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. |
public synchronized void end() {
if (strm != 0) {
end(strm);
strm = 0;
buf = null;
}
}
Closes the compressor and discards any unprocessed input.
This method should be called when the compressor is no longer
being used, but will also be called automatically by the
finalize() method. Once this method is called, the behavior
of the Deflater object is undefined. |
protected void finalize() {
end();
}
Closes the compressor when garbage is collected. |
public synchronized void finish() {
finish = true;
}
When called, indicates that compression should end with the current
contents of the input buffer. |
public synchronized boolean finished() {
return finished;
}
Returns true if the end of the compressed data output stream has
been reached. |
public synchronized int getAdler() {
ensureOpen();
return getAdler(strm);
}
Returns the ADLER-32 value of the uncompressed data. |
public synchronized long getBytesRead() {
ensureOpen();
return getBytesRead(strm);
}
Returns the total number of uncompressed bytes input so far. |
public synchronized long getBytesWritten() {
ensureOpen();
return getBytesWritten(strm);
}
Returns the total number of compressed bytes output so far. |
public int getTotalIn() {
return (int) getBytesRead();
}
Returns the total number of uncompressed bytes input so far.
Since the number of bytes may be greater than
Integer.MAX_VALUE, the #getBytesRead() method is now
the preferred means of obtaining this information. |
public int getTotalOut() {
return (int) getBytesWritten();
}
Returns the total number of compressed bytes output so far.
Since the number of bytes may be greater than
Integer.MAX_VALUE, the #getBytesWritten() method is now
the preferred means of obtaining this information. |
public boolean needsInput() {
return len < = 0;
}
Returns true if the input data buffer is empty and setInput()
should be called in order to provide more input. |
public synchronized void reset() {
ensureOpen();
reset(strm);
finish = false;
finished = false;
off = len = 0;
}
Resets deflater so that a new set of input data can be processed.
Keeps current compression level and strategy settings. |
public void setDictionary(byte[] b) {
setDictionary(b, 0, b.length);
}
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. |
public synchronized void setDictionary(byte[] b,
int off,
int len) {
if (strm == 0 || b == null) {
throw new NullPointerException();
}
if (off < 0 || len < 0 || off > b.length - len) {
throw new ArrayIndexOutOfBoundsException();
}
setDictionary(strm, b, off, 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. |
public void setInput(byte[] b) {
setInput(b, 0, b.length);
}
Sets input data for compression. This should be called whenever
needsInput() returns true indicating that more input data is required. |
public synchronized void setInput(byte[] b,
int off,
int len) {
if (b== null) {
throw new NullPointerException();
}
if (off < 0 || len < 0 || off > b.length - len) {
throw new ArrayIndexOutOfBoundsException();
}
this.buf = b;
this.off = off;
this.len = len;
}
Sets input data for compression. This should be called whenever
needsInput() returns true indicating that more input data is required. |
public synchronized void setLevel(int level) {
if ((level < 0 || level > 9) && level != DEFAULT_COMPRESSION) {
throw new IllegalArgumentException("invalid compression level");
}
if (this.level != level) {
this.level = level;
setParams = true;
}
}
Sets the current compression level to the specified value. |
public synchronized void setStrategy(int strategy) {
switch (strategy) {
case DEFAULT_STRATEGY:
case FILTERED:
case HUFFMAN_ONLY:
break;
default:
throw new IllegalArgumentException();
}
if (this.strategy != strategy) {
this.strategy = strategy;
setParams = true;
}
}
Sets the compression strategy to the specified value. |