loci.formats.codec
Class BitWriter

java.lang.Object
  extended by loci.formats.codec.BitWriter

public class BitWriter
extends Object

A class for writing arbitrary numbers of bits to a byte array.

Source code:
Trac, SVN

Author:
Curtis Rueden ctrueden at wisc.edu

Constructor Summary
BitWriter()
          Constructs a new bit writer.
BitWriter(int size)
          Constructs a new bit writer with the given initial buffer size.
 
Method Summary
static void main(String[] args)
          Tests the BitWriter class.
 byte[] toByteArray()
          Gets an array containing all bits written thus far.
 void write(int value, int numBits)
          Writes the given value using the given number of bits.
 void write(String bitString)
          Writes the bits represented by a bit string to the buffer.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BitWriter

public BitWriter()
Constructs a new bit writer.


BitWriter

public BitWriter(int size)
Constructs a new bit writer with the given initial buffer size.

Method Detail

write

public void write(int value,
                  int numBits)
Writes the given value using the given number of bits.


write

public void write(String bitString)
Writes the bits represented by a bit string to the buffer. All characters in the string must be 0 or 1, or this will throw an IllegalArgumentException


toByteArray

public byte[] toByteArray()
Gets an array containing all bits written thus far.


main

public static void main(String[] args)
Tests the BitWriter class.