org.opencores.util
Class BitStreamWriter
java.lang.Object
|
+--org.opencores.util.BitStreamWriter
- public class BitStreamWriter
- extends java.lang.Object
Class that allows writing bit by bit to file.
Should be constructed using OutputStream or
better BufferedOutputStream.
|
Field Summary |
private int |
buf
(byte) buf which holds current bits |
private int |
nbits
Number of bits in buf |
private java.io.OutputStream |
stream
Output stream |
|
Constructor Summary |
BitStreamWriter(java.io.OutputStream stream)
Constructs new bitstream writer.
|
|
Method Summary |
void |
close()
Closes stream. |
void |
write(int bit)
Writes one bit to the stream. |
void |
write(int data,
int nb)
Writes nb bits to the stream.
|
| Methods inherited from class java.lang.Object |
,
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
registerNatives,
toString,
wait,
wait,
wait |
buf
private int buf
- (byte) buf which holds current bits
nbits
private int nbits
- Number of bits in
buf
stream
private java.io.OutputStream stream
- Output stream
BitStreamWriter
public BitStreamWriter(java.io.OutputStream stream)
- Constructs new bitstream writer.
Example:
BitStreamWriter stream = new BitStreamWriter(new BufferedOutputStream(new FileOutputStream("abc.bin")));
- Parameters:
stream - output stream
write
public void write(int data,
int nb)
throws java.io.IOException
- Writes
nb bits to the stream.
nb <= 24.
- Parameters:
data - bit sequence to writenbits - number of bits to write
write
public void write(int bit)
throws java.io.IOException
- Writes one bit to the stream.
- Parameters:
bit - bit to write
close
public void close()
throws java.io.IOException
- Closes stream.