org.at4j.comp.bzip2
Class BZip2InputStream

java.lang.Object
  extended by java.io.InputStream
      extended by org.at4j.comp.bzip2.BZip2InputStream
All Implemented Interfaces:
Closeable

public class BZip2InputStream
extends InputStream

This is an InputStream for reading bzip2 encoded data.

For more information on the inner workings of bzip2, see the Wikipedia article on bzip2.

This stream is not safe for concurrent access by several writing threads. A client must provide external synchronization to use this from several threads.

Since:
1.1
Author:
Karl Gustafsson
See Also:
BZip2InputStreamSettings, BZip2OutputStream

Constructor Summary
BZip2InputStream(InputStream in)
          Create a new bzip2 input stream that will read compressed data from in.
BZip2InputStream(InputStream in, BZip2InputStreamSettings settings)
          Create a new bzip2 input stream that will read compressed data from in.
 
Method Summary
 void close()
           
protected  void finalize()
          Close the stream if the client has been sloppy about it.
 int read()
           
 int read(byte[] barr)
           
 int read(byte[] barr, int off, int len)
           
 
Methods inherited from class java.io.InputStream
available, mark, markSupported, reset, skip
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BZip2InputStream

public BZip2InputStream(InputStream in)
                 throws IOException
Create a new bzip2 input stream that will read compressed data from in.

Parameters:
in - The stream to read compressed data from.
Throws:
IOException - On errors when reading the file header.
See Also:
BZip2InputStream(InputStream, BZip2InputStreamSettings)

BZip2InputStream

public BZip2InputStream(InputStream in,
                        BZip2InputStreamSettings settings)
                 throws IOException
Create a new bzip2 input stream that will read compressed data from in.

Parameters:
in - The stream to read compressed data from.
settings - Settings for the decoder.
Throws:
IOException - On errors when reading the file header.
See Also:
BZip2InputStream(InputStream)
Method Detail

read

public int read()
         throws IOException
Specified by:
read in class InputStream
Throws:
IOException

read

public int read(byte[] barr)
         throws IOException
Overrides:
read in class InputStream
Throws:
IOException

read

public int read(byte[] barr,
                int off,
                int len)
         throws IOException,
                IndexOutOfBoundsException
Overrides:
read in class InputStream
Throws:
IOException
IndexOutOfBoundsException

close

public void close()
           throws IOException
Specified by:
close in interface Closeable
Overrides:
close in class InputStream
Throws:
IOException

finalize

protected void finalize()
                 throws Throwable
Close the stream if the client has been sloppy about it.

Overrides:
finalize in class Object
Throws:
Throwable