java.util.zip
Class InflaterInputStream

java.lang.Object
  extended by java.io.InputStream
      extended by java.io.FilterInputStream
          extended by java.util.zip.InflaterInputStream
All Implemented Interfaces:
Closeable
Direct Known Subclasses:
GZIPInputStream, ZipInputStream

public class InflaterInputStream
extends FilterInputStream

This filter stream is used to decompress data compressed in the "deflate" format. The "deflate" format is described in RFC 1951. This stream may form the basis for other decompression filters, such as the GZIPInputStream.

Since:
1.1

Field Summary
protected  byte[] buf
          Byte array used as a buffer
protected  Inflater inf
          Decompressor for this filter
protected  int len
          Size of buffer
 
Fields inherited from class java.io.FilterInputStream
in
 
Constructor Summary
InflaterInputStream(InputStream in)
          Create an InflaterInputStream with the default decompresseor and a default buffer size.
InflaterInputStream(InputStream in, Inflater inf)
          Create an InflaterInputStream with the specified decompresseor and a default buffer size.
InflaterInputStream(InputStream in, Inflater inf, int size)
          Create an InflaterInputStream with the specified decompresseor and a specified buffer size.
 
Method Summary
 int available()
          Returns 0 once the end of the stream (EOF) has been reached.
 void close()
          Closes the input stream
protected  void fill()
          Fills the buffer with more data to decompress.
 void mark(int readLimit)
          Calls the in.mark(int) method.
 boolean markSupported()
          Calls the in.markSupported() method.
 int read()
          Reads one byte of decompressed data.
 int read(byte[] b, int off, int len)
          Decompresses data into the byte array
 void reset()
          Calls the in.reset() method.
 long skip(long n)
          Skip specified number of bytes of uncompressed data
 
Methods inherited from class java.io.FilterInputStream
read
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

inf

protected Inflater inf
Decompressor for this filter


buf

protected byte[] buf
Byte array used as a buffer


len

protected int len
Size of buffer

Constructor Detail

InflaterInputStream

public InflaterInputStream(InputStream in)
Create an InflaterInputStream with the default decompresseor and a default buffer size.

Parameters:
in - the InputStream to read bytes from

InflaterInputStream

public InflaterInputStream(InputStream in,
                           Inflater inf)
Create an InflaterInputStream with the specified decompresseor and a default buffer size.

Parameters:
in - the InputStream to read bytes from
inf - the decompressor used to decompress data read from in

InflaterInputStream

public InflaterInputStream(InputStream in,
                           Inflater inf,
                           int size)
Create an InflaterInputStream with the specified decompresseor and a specified buffer size.

Parameters:
in - the InputStream to read bytes from
inf - the decompressor used to decompress data read from in
size - size of the buffer to use
Method Detail

available

public int available()
              throws IOException
Returns 0 once the end of the stream (EOF) has been reached. Otherwise returns 1.

Overrides:
available in class FilterInputStream
Returns:
The value returned from in.available()
Throws:
IOException - If an error occurs

close

public void close()
           throws IOException
Closes the input stream

Specified by:
close in interface Closeable
Overrides:
close in class FilterInputStream
Throws:
IOException - If an error occurs

fill

protected void fill()
             throws IOException
Fills the buffer with more data to decompress.

Throws:
IOException

read

public int read()
         throws IOException
Reads one byte of decompressed data. The byte is in the lower 8 bits of the int.

Overrides:
read in class FilterInputStream
Returns:
The value returned from in.read()
Throws:
IOException - If an error occurs

read

public int read(byte[] b,
                int off,
                int len)
         throws IOException
Decompresses data into the byte array

Overrides:
read in class FilterInputStream
Parameters:
b - the array to read and decompress data into
off - the offset indicating where the data should be placed
len - the number of bytes to decompress
Returns:
The value retured from in.read(byte[], int, int)
Throws:
IOException - If an error occurs

skip

public long skip(long n)
          throws IOException
Skip specified number of bytes of uncompressed data

Overrides:
skip in class FilterInputStream
Parameters:
n - number of bytes to skip
Returns:
The value returned from in.skip(long)
Throws:
IOException - If an error occurs

markSupported

public boolean markSupported()
Description copied from class: FilterInputStream
Calls the in.markSupported() method.

Overrides:
markSupported in class FilterInputStream
Returns:
true if mark/reset is supported, false otherwise

mark

public void mark(int readLimit)
Description copied from class: FilterInputStream
Calls the in.mark(int) method.

Overrides:
mark in class FilterInputStream
Parameters:
readLimit - The parameter passed to in.mark(int)

reset

public void reset()
           throws IOException
Description copied from class: FilterInputStream
Calls the in.reset() method.

Overrides:
reset in class FilterInputStream
Throws:
IOException - If an error occurs