java.util.zip
Class Inflater
Inflater is used to decompress data that has been compressed according
to the "deflate" standard described in rfc1950.
The usage is as following. First you have to set some input with
setInput()
, then inflate() it. If inflate doesn't
inflate any bytes there may be three reasons:
- needsInput() returns true because the input buffer is empty.
You have to provide more input with
setInput()
.
NOTE: needsInput() also returns true when, the stream is finished.
- needsDictionary() returns true, you have to provide a preset
dictionary with
setDictionary()
. - finished() returns true, the inflater has finished.
Once the first output byte is produced, a dictionary will not be
needed at a later stage.
Inflater() - Creates a new inflater.
|
Inflater(boolean noHeader) - Creates a new inflater.
|
void | end() - Just clear all references to inflater instead.
|
protected void | finalize() - Finalizes this object.
|
boolean | finished() - Returns true, if the inflater has finished.
|
int | getAdler() - Gets the adler checksum.
|
int | getRemaining() - Gets the number of unprocessed input.
|
int | getTotalIn() - Gets the total number of processed compressed input bytes.
|
int | getTotalOut() - Gets the total number of output bytes returned by inflate().
|
int | inflate(byte[] buf) - Inflates the compressed stream to the output buffer.
|
int | inflate(byte[] buf, int off, int len) - Inflates the compressed stream to the output buffer.
|
boolean | needsDictionary() - Returns true, if a preset dictionary is needed to inflate the input.
|
boolean | needsInput() - Returns true, if the input buffer is empty.
|
void | reset() - Resets the inflater so that a new stream can be decompressed.
|
void | setDictionary(byte[] buf) - Sets the preset dictionary.
|
void | setDictionary(byte[] buf, int off, int len) - Sets the preset dictionary.
|
void | setInput(byte[] buf) - Sets the input.
|
void | setInput(byte[] buf, int off, int len) - Sets the input.
|
clone , equals , extends Object> getClass , finalize , hashCode , notify , notifyAll , toString , wait , wait , wait |
Inflater
public Inflater()
Creates a new inflater.
Inflater
public Inflater(boolean noHeader)
Creates a new inflater.
end
public void end()
Just clear all references to inflater instead.
Frees all objects allocated by the inflater. There's no reason
to call this, since you can just rely on garbage collection (even
for the Sun implementation). Exists only for compatibility
with Sun's JDK, where the compressor allocates native memory.
If you call any method (even reset) afterwards the behaviour is
undefined.
finished
public boolean finished()
Returns true, if the inflater has finished. This means, that no
input is needed and no output can be produced.
getAdler
public int getAdler()
Gets the adler checksum. This is either the checksum of all
uncompressed bytes returned by inflate(), or if needsDictionary()
returns true (and thus no output was yet produced) this is the
adler checksum of the expected dictionary.
getRemaining
public int getRemaining()
Gets the number of unprocessed input. Useful, if the end of the
stream is reached and you want to further process the bytes after
the deflate stream.
- the number of bytes of the input which were not processed.
getTotalIn
public int getTotalIn()
Gets the total number of processed compressed input bytes.
- the total number of bytes of processed input bytes.
getTotalOut
public int getTotalOut()
Gets the total number of output bytes returned by inflate().
- the total number of output bytes.
inflate
public int inflate(byte[] buf)
throws DataFormatException
Inflates the compressed stream to the output buffer. If this
returns 0, you should check, whether needsDictionary(),
needsInput() or finished() returns true, to determine why no
further output is produced.
- the number of bytes written to the buffer, 0 if no further
output can be produced.
inflate
public int inflate(byte[] buf,
int off,
int len)
throws DataFormatException
Inflates the compressed stream to the output buffer. If this
returns 0, you should check, whether needsDictionary(),
needsInput() or finished() returns true, to determine why no
further output is produced.
off
- the offset into buffer where the output should start.len
- the maximum length of the output.
- the number of bytes written to the buffer, 0 if no further
output can be produced.
needsDictionary
public boolean needsDictionary()
Returns true, if a preset dictionary is needed to inflate the input.
needsInput
public boolean needsInput()
Returns true, if the input buffer is empty.
You should then call setInput().
NOTE: This method also returns true when the stream is finished.
reset
public void reset()
Resets the inflater so that a new stream can be decompressed. All
pending input and output will be discarded.
setDictionary
public void setDictionary(byte[] buf)
Sets the preset dictionary. This should only be called, if
needsDictionary() returns true and it should set the same
dictionary, that was used for deflating. The getAdler()
function returns the checksum of the dictionary needed.
setDictionary
public void setDictionary(byte[] buf,
int off,
int len)
Sets the preset dictionary. This should only be called, if
needsDictionary() returns true and it should set the same
dictionary, that was used for deflating. The getAdler()
function returns the checksum of the dictionary needed.
off
- the offset into buffer where the dictionary starts.len
- the length of the dictionary.
setInput
public void setInput(byte[] buf)
Sets the input. This should only be called, if needsInput()
returns true.
setInput
public void setInput(byte[] buf,
int off,
int len)
Sets the input. This should only be called, if needsInput()
returns true.
off
- the offset into buffer where the input starts.len
- the length of the input.
Inflater.java - Decompress a data stream
Copyright (C) 1999, 2000, 2001, 2003 Free Software Foundation, Inc.
This file is part of GNU Classpath.
GNU Classpath is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
GNU Classpath is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
conditions of the GNU General Public License cover the whole
combination.
As a special exception, the copyright holders of this library give you
permission to link this library with independent modules to produce an
executable, regardless of the license terms of these independent
modules, and to copy and distribute the resulting executable under
terms of your choice, provided that you also meet, for each linked
independent module, the terms and conditions of the license of that
module. An independent module is a module which is not derived from
or based on this library. If you modify this library, you may extend
this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this
exception statement from your version.