Build 1.0_r1(from source)

java.util.zip
Class Inflater

java.lang.Object
  extended by java.util.zip.Inflater

public class Inflater
extends Object

The Inflater class is used to decompress bytes using the DEFLATE compression algorithm. Inflation is performed by the ZLIB compression library.

See Also:
DeflaterOutputStream, Inflater

Field Summary
(package private)  int inLength
           
(package private)  int inRead
           
 
Constructor Summary
Inflater()
          Constructs a new Inflater instance.
Inflater(boolean noHeader)
          Constructs a new Inflater instance.
 
Method Summary
 void end()
          Release any resources associated with this Inflater.
protected  void finalize()
          Called by the virtual machine when there are no longer any (non-weak) references to the receiver.
 boolean finished()
          Indicates if the Inflater has inflated the entire deflated stream.
 int getAdler()
          Returns the Adler32 checksum of either all bytes inflated, or the checksum of the preset dictionary if one has been supplied.
 long getBytesRead()
          Returns a long int of total number of bytes of input read by the Inflater.
 long getBytesWritten()
          Returns a long int of total number of bytes of input output by the Inflater.
 int getRemaining()
          Returns the number of bytes of current input remaining to be read by the inflater
 int getTotalIn()
          Returns total number of bytes of input read by the Inflater.
 int getTotalOut()
          Returns total number of bytes of input output by the Inflater.
 int inflate(byte[] buf)
          Inflates bytes from current input and stores them in buf.
 int inflate(byte[] buf, int off, int nbytes)
          Inflates up to nbytes bytes from current input and stores them in buf starting at off.
 boolean needsDictionary()
          Indicates whether the input bytes were compressed with a preset dictionary.
 boolean needsInput()
           
 void reset()
          Resets the Inflater.
 void setDictionary(byte[] buf)
          Sets the preset dictionary to be used for inflation to buf.
 void setDictionary(byte[] buf, int off, int nbytes)
           
(package private)  int setFileInput(FileDescriptor fd, long off, int nbytes)
          Sets the current input to the region within a file starting at off and ending at nbytes - 1.
 void setInput(byte[] buf)
          Sets the current input to buf.
 void setInput(byte[] buf, int off, int nbytes)
          Sets the current input to the region of buf starting at off and ending at nbytes - 1.
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

inRead

int inRead

inLength

int inLength
Constructor Detail

Inflater

public Inflater()
Constructs a new Inflater instance.


Inflater

public Inflater(boolean noHeader)
Constructs a new Inflater instance. If noHeader is true the Inflater will not attempt to read a ZLIB header.

Parameters:
noHeader - If true, read a ZLIB header from input.
Method Detail

end

public void end()
Release any resources associated with this Inflater. Any unused input/output is discarded. This is also called by the finalize method.


finalize

protected void finalize()
Description copied from class: Object
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.

Overrides:
finalize in class Object

finished

public boolean finished()
Indicates if the Inflater has inflated the entire deflated stream. If deflated bytes remain and needsInput returns true this method will return false. This method should be called after all deflated input is supplied to the Inflater.

Returns:
True if all input has been inflated, false otherwise

getAdler

public int getAdler()
Returns the Adler32 checksum of either all bytes inflated, or the checksum of the preset dictionary if one has been supplied.

Returns:
The Adler32 checksum associated with this Inflater.

getRemaining

public int getRemaining()
Returns the number of bytes of current input remaining to be read by the inflater

Returns:
Number of bytes of unread input.

getTotalIn

public int getTotalIn()
Returns total number of bytes of input read by the Inflater.

Returns:
Total bytes read

getTotalOut

public int getTotalOut()
Returns total number of bytes of input output by the Inflater.

Returns:
Total bytes output

inflate

public int inflate(byte[] buf)
            throws DataFormatException
Inflates bytes from current input and stores them in buf.

Parameters:
buf - Buffer to output inflated bytes
Returns:
Number of bytes inflated
Throws:
DataFormatException - If the underlying stream is corrupted or was not DEFLATED

inflate

public int inflate(byte[] buf,
                   int off,
                   int nbytes)
            throws DataFormatException
Inflates up to nbytes bytes from current input and stores them in buf starting at off.

Parameters:
buf - Buffer to output inflated bytes
off - Offset in buffer into which to store inflated bytes
nbytes - Number of inflated bytes to store
Returns:
Number of bytes inflated
Throws:
DataFormatException - If the underlying stream is corrupted or was not DEFLATED

needsDictionary

public boolean needsDictionary()
Indicates whether the input bytes were compressed with a preset dictionary. This method should be called prior to inflate() to determine if a dictionary is required. If so setDictionary() should be called with the appropriate dictionary prior to calling inflate().

Returns:
true if a preset dictionary is required for inflation.
See Also:
setDictionary(byte[]), setDictionary(byte[], int, int)

needsInput

public boolean needsInput()

reset

public void reset()
Resets the Inflater.


setDictionary

public void setDictionary(byte[] buf)
Sets the preset dictionary to be used for inflation to buf. needsDictionary() can be called to determine whether the current input was deflated using a preset dictionary.

Parameters:
buf - The buffer containing the dictionary bytes
See Also:
needsDictionary

setDictionary

public void setDictionary(byte[] buf,
                          int off,
                          int nbytes)

setInput

public void setInput(byte[] buf)
Sets the current input to buf. This method should only be called if needsInput() returns true.

Parameters:
buf - input buffer
See Also:
needsInput()

setInput

public void setInput(byte[] buf,
                     int off,
                     int nbytes)
Sets the current input to the region of buf starting at off and ending at nbytes - 1. This method should only be called if needsInput() returns true.

Parameters:
buf - input buffer
off - offset to read from in buffer
nbytes - number of bytes to read
See Also:
needsInput()

setFileInput

int setFileInput(FileDescriptor fd,
                 long off,
                 int nbytes)
Sets the current input to the region within a file starting at off and ending at nbytes - 1. This method should only be called if needsInput() returns true.

Parameters:
file - input file
off - offset to read from in buffer
nbytes - number of bytes to read
See Also:
needsInput()

getBytesRead

public long getBytesRead()
Returns a long int of total number of bytes of input read by the Inflater. This method performs the same as getTotalIn except it returns a long value instead of an integer

Returns:
Total bytes read

getBytesWritten

public long getBytesWritten()
Returns a long int of total number of bytes of input output by the Inflater. This method performs the same as getTotalOut except it returns a long value instead of an integer

Returns:
Total bytes output

Build 1.0_r1(from source)

Please submit a feedback, bug or feature