net.sf.jazzlib
Class InflaterInputStream

java.lang.Object
  extended by java.io.InputStream
      extended by java13.io.FilterInputStream
          extended by net.sf.jazzlib.InflaterInputStream
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
Author:
John Leuner, Tom Tromey

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 java13.io.FilterInputStream
in
 
Constructor Summary
InflaterInputStream(java.io.InputStream in)
          Create an InflaterInputStream with the default decompresseor and a default buffer size.
InflaterInputStream(java.io.InputStream in, Inflater inf)
          Create an InflaterInputStream with the specified decompresseor and a default buffer size.
InflaterInputStream(java.io.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.
 int read()
          Reads one byte of decompressed data.
 int read(byte[] b, int off, int len)
          Decompresses data into the byte array
 long skip(long n)
          Skip specified number of bytes of uncompressed data
 
Methods inherited from class java13.io.FilterInputStream
mark, markSupported, read, reset
 
Methods inherited from class java.lang.Object
equals, 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(java.io.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(java.io.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(java.io.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 java.io.IOException
Returns 0 once the end of the stream (EOF) has been reached. Otherwise returns 1.

Overrides:
available in class FilterInputStream
Returns:
the number of bytes that can be read from the input stream without blocking.
Throws:
java.io.IOException - if an I/O error occurs.
See Also:
java.io.FilterInputStream#in

close

public void close()
           throws java.io.IOException
Closes the input stream

Overrides:
close in class FilterInputStream
Throws:
java.io.IOException - if an I/O error occurs.
See Also:
java.io.FilterInputStream#in

fill

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

Throws:
java.io.IOException

read

public int read()
         throws java.io.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 next byte of data, or -1 if the end of the stream is reached.
Throws:
java.io.IOException - if an I/O error occurs.
See Also:
java.io.FilterInputStream#in

read

public int read(byte[] b,
                int off,
                int len)
         throws java.io.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 total number of bytes read into the buffer, or -1 if there is no more data because the end of the stream has been reached.
Throws:
java.io.IOException - if an I/O error occurs.
See Also:
java.io.FilterInputStream#in

skip

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

Overrides:
skip in class FilterInputStream
Parameters:
n - number of bytes to skip
Returns:
the actual number of bytes skipped.
Throws:
java.io.IOException - if an I/O error occurs.