loci.formats.codec
Class CBZip2InputStream

java.lang.Object
  extended by java.io.InputStream
      extended by loci.formats.codec.CBZip2InputStream
All Implemented Interfaces:
Closeable, BZip2Constants

public class CBZip2InputStream
extends InputStream
implements BZip2Constants

An input stream that decompresses from the BZip2 format (without the file header chars) to be read as any other stream.

The decompression requires large amounts of memory. Thus you should call the close() method as soon as possible, to force CBZip2InputStream to release the allocated memory.

CBZip2InputStream reads bytes from the compressed source stream via the single byte read() method exclusively. Thus you should consider to use a buffered source stream.

Instances of this class are not threadsafe.

Source code:
Trac, SVN


Field Summary
 
Fields inherited from interface loci.formats.codec.BZip2Constants
BASE_BLOCK_SIZE, G_SIZE, MAX_ALPHA_SIZE, MAX_CODE_LEN, MAX_SELECTORS, N_GROUPS, N_ITERS, NUM_OVERSHOOT_BYTES, R_NUMS, RUNA, RUNB
 
Constructor Summary
CBZip2InputStream(InputStream in)
          Constructs a new CBZip2InputStream which decompresses bytes read from the specified stream.
 
Method Summary
 void close()
           
 int read()
           
 int read(byte[] dest, int offs, int len)
           
 
Methods inherited from class java.io.InputStream
available, mark, markSupported, read, reset, skip
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CBZip2InputStream

public CBZip2InputStream(InputStream in)
                  throws IOException
Constructs a new CBZip2InputStream which decompresses bytes read from the specified stream.

Although BZip2 headers are marked with the magic "Bz" this constructor expects the next byte in the stream to be the first one after the magic. Thus callers have to skip the first two bytes. Otherwise this constructor will throw an exception.

Throws:
IOException - if the stream content is malformed or an I/O error occurs.
NullPointerException - if in == null
Method Detail

read

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

read

public int read(byte[] dest,
                int offs,
                int len)
         throws IOException
Overrides:
read in class InputStream
Throws:
IOException

close

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