Index (Frames) | Index (No Frames) | Package | Package Tree | Tree
java.util.zip

Class Inflater

java.lang.Object
|
+--java.util.zip.Inflater


public class Inflater

extends Object

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: Once the first output byte is produced, a dictionary will not be needed at a later stage.

Since:Author:

Constructor Summary

Inflater()

Creates a new inflater.
Inflater(boolean nowrap)

Creates a new inflater.

Method Summary

voidend()

Frees all objects allocated by the inflater.
voidfinalize()

Finalizes this object.
booleanfinished()

Returns true, if the inflater has finished.
intgetAdler()

Gets the adler checksum.
intgetRemaining()

Gets the number of unprocessed input.
intgetTotalIn()

Gets the total number of processed compressed input bytes.
intgetTotalOut()

Gets the total number of output bytes returned by inflate().
intinflate(byte[] buf)

Inflates the compressed stream to the output buffer.
intinflate(byte[] buf, int off, int len)

Inflates the compressed stream to the output buffer.
booleanneedsDictionary()

Returns true, if a preset dictionary is needed to inflate the input.
booleanneedsInput()

Returns true, if the input buffer is empty.
voidreset()

Resets the inflater so that a new stream can be decompressed.
voidsetDictionary(byte[] buffer)

Sets the preset dictionary.
voidsetDictionary(byte[] buffer, int off, int len)

Sets the preset dictionary.
voidsetInput(byte[] buf)

Sets the input.
voidsetInput(byte[] buf, int off, int len)

Sets the input.

Constructor Details

Inflater

public Inflater()

Creates a new inflater.


Inflater

public Inflater(boolean nowrap)

Creates a new inflater.

Parameters:


Method Details

end

public void end()

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.


finalize

protected void finalize()

Finalizes this object.


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.

Returns:


getTotalIn

public int getTotalIn()

Gets the total number of processed compressed input bytes.

Returns:


getTotalOut

public int getTotalOut()

Gets the total number of output bytes returned by inflate().

Returns:


inflate

public int inflate(byte[] buf)

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.

Parameters:

Returns:

Throws:


inflate

public int inflate(byte[] buf, int off, int len)

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.

Parameters:

Returns:

Throws:


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[] buffer)

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.

Parameters:

Throws:


setDictionary

public void setDictionary(byte[] buffer, 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.

Parameters:

Throws:


setInput

public void setInput(byte[] buf)

Sets the input. This should only be called, if needsInput() returns true.

Parameters:

Throws:


setInput

public void setInput(byte[] buf, int off, int len)

Sets the input. This should only be called, if needsInput() returns true.

Parameters:

Throws: