com.imagero.uio.io
Class BitOutputStream

java.lang.Object
  extended byjava.io.OutputStream
      extended byjava.io.FilterOutputStream
          extended bycom.imagero.uio.io.BitOutputStream

public class BitOutputStream
extends java.io.FilterOutputStream

adds ability to write streams bitewise


Field Summary
protected  boolean invertBitOrder
           
protected  int vbits
           
 
Fields inherited from class java.io.FilterOutputStream
out
 
Constructor Summary
BitOutputStream(java.io.OutputStream out)
           
 
Method Summary
 void flush()
          writes bits from buffer to output stream
 int getBitsToWrite()
           
 boolean isInvertBitOrder()
           
 void setBitsToWrite(int bitsToWrite)
          set how much bits should be written to stream every write() call
 void setInvertBitOrder(boolean invertBitOrder)
           
 void write(byte[] b)
          Writes b.length bytes to output stream.
 void write(byte[] b, int off, int len)
          Writes len bytes from byte array starting at given offset to output stream.
 void write(int b)
          Writes some bits (max 8) from the specified int to stream.
 void write(int b, int nbits)
          Writes some bits (max 8) from the specified int to stream.
 
Methods inherited from class java.io.FilterOutputStream
close
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

vbits

protected int vbits

invertBitOrder

protected boolean invertBitOrder
Constructor Detail

BitOutputStream

public BitOutputStream(java.io.OutputStream out)
Method Detail

getBitsToWrite

public int getBitsToWrite()

setBitsToWrite

public void setBitsToWrite(int bitsToWrite)
set how much bits should be written to stream every write() call

Parameters:
bitsToWrite -

isInvertBitOrder

public boolean isInvertBitOrder()

setInvertBitOrder

public void setInvertBitOrder(boolean invertBitOrder)

write

public void write(int b)
           throws java.io.IOException
Writes some bits (max 8) from the specified int to stream.

Parameters:
b - int which should be written
Throws:
java.io.IOException - if an I/O error occurs
See Also:
setBitsToWrite(int), getBitsToWrite()

write

public void write(int b,
                  int nbits)
           throws java.io.IOException
Writes some bits (max 8) from the specified int to stream.

Parameters:
b - int which should be written
nbits - bit count to write
Throws:
java.io.IOException - if an I/O error occurs

flush

public void flush()
           throws java.io.IOException
writes bits from buffer to output stream

Throws:
java.io.IOException - if I/O error occurs

write

public void write(byte[] b)
           throws java.io.IOException
Writes b.length bytes to output stream. Only first getBitsToWrite() from every byte are written to stream.

Parameters:
b - the data to be written.
Throws:
java.io.IOException - if an I/O error occurs.

write

public void write(byte[] b,
                  int off,
                  int len)
           throws java.io.IOException
Writes len bytes from byte array starting at given offset to output stream. Only first getBitsToWrite() from every byte are written to stream.

Parameters:
b - the data to be written.
off - the start offset in the data.
len - the number of bytes to write.
Throws:
java.io.IOException - if I/O error occurs