it.geosolutions.io.input
Class BitInputStream

Object
  extended by InputStream
      extended by FilterInputStream
          extended by BitInputStream
All Implemented Interfaces:
Closeable

public final class BitInputStream
extends FilterInputStream

This class is an input stream wrapper that can read a specific number of bytes and bits from an input stream.

Author:
Benjamin Stark, Simone Giannecchini

Field Summary
 
Fields inherited from class FilterInputStream
in
 
Constructor Summary
BitInputStream(InputStream in)
          Constructs a bit input stream from an InputStream object.
 
Method Summary
 byte[] read(int length)
          Read specific number of bytes from the input stream.
 int readSBits(int numBits)
          Read a signed value from the given number of bits
 long readUBits(int numBits)
          Read an unsigned value from the given number of bits.
 int readUI8()
          Read an unsigned 8 bit value.
 int[] readUI8(int length)
          Read specific number of unsigned bytes from the input stream.
 
Methods inherited from class FilterInputStream
available, close, mark, markSupported, read, read, read, reset, skip
 
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BitInputStream

public BitInputStream(InputStream in)
Constructs a bit input stream from an InputStream object.

Parameters:
in - input stream that will be wrapped
Method Detail

readUI8

public int readUI8()
            throws IOException
Read an unsigned 8 bit value.

Returns:
unsigned 8 bit value as integer
Throws:
IOException

readUI8

public int[] readUI8(int length)
              throws IOException
Read specific number of unsigned bytes from the input stream.

Parameters:
length - number of bytes to read and return as integers
Returns:
unsigned bytes as integer values
Throws:
IOException

read

public byte[] read(int length)
            throws IOException
Read specific number of bytes from the input stream.

Parameters:
length - number of bytes to read
Returns:
array of read bytes
Throws:
IOException

readUBits

public long readUBits(int numBits)
               throws IOException
Read an unsigned value from the given number of bits.

Parameters:
numBits - number of bits used for the unsigned value
Returns:
value read from numBits bits as long
Throws:
IOException

readSBits

public int readSBits(int numBits)
              throws IOException
Read a signed value from the given number of bits

Parameters:
numBits - number of bits used for the signed value
Returns:
value read from numBits bits as integer
Throws:
IOException


Copyright © 2006-2010 GeoSolutions. All Rights Reserved.