Android
java.util.zip
public class

java.util.zip.Inflater

java.lang.Object
java.util.zip.Inflater

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

Summary

Public Constructors

            Inflater()
Constructs a new Inflater instance.
            Inflater(boolean noHeader)
Constructs a new Inflater instance.

Public Methods

  synchronized        void  end()
Release any resources associated with this Inflater.
  synchronized        boolean  finished()
Indicates if the Inflater has inflated the entire deflated stream.
  synchronized        int  getAdler()
Returns the Adler32 checksum of either all bytes inflated, or the checksum of the preset dictionary if one has been supplied.
  synchronized        long  getBytesRead()
Returns a long int of total number of bytes of input read by the Inflater.
  synchronized        long  getBytesWritten()
Returns a long int of total number of bytes of input output by the Inflater.
  synchronized        int  getRemaining()
Returns the number of bytes of current input remaining to be read by the inflater
  synchronized        int  getTotalIn()
Returns total number of bytes of input read by the Inflater.
  synchronized        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.
  synchronized        int  inflate(byte[] buf, int off, int nbytes)
Inflates up to nbytes bytes from current input and stores them in buf starting at off.
  synchronized        boolean  needsDictionary()
Indicates whether the input bytes were compressed with a preset dictionary.
  synchronized        boolean  needsInput()
  synchronized        void  reset()
Resets the Inflater.
  synchronized        void  setDictionary(byte[] buf, int off, int nbytes)
  synchronized        void  setDictionary(byte[] buf)
Sets the preset dictionary to be used for inflation to buf.
  synchronized        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.
  synchronized        void  setInput(byte[] buf)
Sets the current input to buf.

Protected Methods

          void  finalize()
Called by the virtual machine when there are no longer any (non-weak) references to the receiver.
Methods inherited from class java.lang.Object

Details

Public Constructors

public Inflater()

Constructs a new Inflater instance.

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.

Public Methods

public synchronized void end()

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

public synchronized 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

public synchronized 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.

public synchronized 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

public synchronized 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

public synchronized int getRemaining()

Returns the number of bytes of current input remaining to be read by the inflater

Returns

  • Number of bytes of unread input.

public synchronized int getTotalIn()

Returns total number of bytes of input read by the Inflater.

Returns

  • Total bytes read

public synchronized int getTotalOut()

Returns total number of bytes of input output by the Inflater.

Returns

  • Total bytes output

public int inflate(byte[] buf)

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

public synchronized int inflate(byte[] buf, int off, int nbytes)

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

public synchronized 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.

public synchronized boolean needsInput()

public synchronized void reset()

Resets the Inflater.

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

public synchronized 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

public synchronized 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

public synchronized 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

Protected Methods

protected void finalize()

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.

Copyright 2007 Google Inc. Build 0.9_r1-98467 - 14 Aug 2008 18:56