|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.io.OutputStream
BitOutputStream
This class is a buffered output stream that allows for users to easily write bits and bytes to the underlying stream. All methods use computer arithmetic to maipulate the bits, and have a default buffer of 64 bits (long).
Usage: Identical to the BufferedOutputStream. ie. BitOutputStream out = new BitOutputStream(new FileOutputStream(file));
Field Summary | |
protected long |
buf
The 'long' buffer that stores the bits. |
protected int |
bufLength
A 'long' is represented by 64 bits, thus the length of the buffer is 64 bits. |
protected long[] |
byteLReduce
The reduce arrays used to reduce large values. |
protected int |
count
The current location in the buffer. |
protected long[] |
outReduce
The reduce arrays used to reduce large values. |
Constructor Summary | |
BitOutputStream(java.io.OutputStream os)
Initialize all variables needed for this stream. |
Method Summary | |
void |
close()
Closes this output stream and releases any system resources associated with this stream. |
void |
flush()
Flushes this output stream and forces any buffered output bytes to be written out. |
java.lang.String |
toString()
Returns a String representation of the state of the current buffer in binary form, as well as any variables associated with the buffer. |
void |
write(byte[] b)
Writes b.length bytes from the specified byte array to this output stream. |
void |
write(byte[] b,
int off,
int len)
Writes len bytes from the specified byte array starting at offset off to this output stream. |
void |
write(int b)
Writes the specified byte to this output stream. |
void |
writeBit(boolean b)
Writes a specified bit to the buffer, and if needed, the output stream specified. |
void |
writeBit(byte b)
Writes a specified bit to the buffer, and if needed, the output stream specified. |
void |
writeBits(boolean[] b,
int off,
int len)
Writes a series of bits to the buffer, and if needed, the output stream specified. |
void |
writeBits(java.lang.String str,
int off,
int len)
Writes a series of bits to the buffer, and if needed, the output stream specified. |
void |
writeByte(byte a)
Writes a UNSIGNED byte to the buffer. |
void |
writeBytes(byte[] b,
int off,
int len)
Writes len bytes from the specified byte array starting at offset off to this output stream. |
void |
writeInt(int i)
Writes an int to the buffer, and if needed, the output stream specified. |
void |
writeLong(long l)
Writes a long to the buffer and/or output stream. |
void |
writeString(java.lang.String str,
int off,
int len)
Writes a String to the buffer, in char form. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
protected long buf
protected int bufLength
protected int count
protected long[] byteLReduce
protected long[] outReduce
Constructor Detail |
public BitOutputStream(java.io.OutputStream os)
os
- the OutputStream to write to.Method Detail |
public void close() throws java.io.IOException
java.io.IOException
public void flush() throws java.io.IOException
java.io.IOException
public void write(byte[] b) throws java.io.IOException
b
- the byte array to be written.
java.io.IOException
public void write(int b) throws java.io.IOException
b
- the byte to be written.
java.io.IOException
public void write(byte[] b, int off, int len) throws java.io.IOException
b
- the byte array to be written.off
- the offset from the beginning of the array.len
- the number of bytes of the array to be written.
java.io.IOException
public void writeBytes(byte[] b, int off, int len) throws java.io.IOException
b
- the byte array to be written.off
- the offset from the beginning of the array.len
- the number of bytes of the array to be written.
java.io.IOException
public void writeByte(byte a) throws java.io.IOException
a
- the byte to be written.
java.io.IOException
public void writeBit(boolean b) throws java.io.IOException
b
- the bit to be written.
java.io.IOException
public void writeBit(byte b) throws java.io.IOException
b
- the byte that represents the bit to be written. See method description.
java.io.IOException
public void writeBits(boolean[] b, int off, int len) throws java.io.IOException
b
- the boolean array representing the bits from left to right.off
- the offset from the beginning of the array.len
- the number of bits of the array to be written.
java.io.IOException
public void writeBits(java.lang.String str, int off, int len) throws java.io.IOException
str
- the String to be written.off
- the offset from the beginning of the String.len
- the number of characters of the String to be written.
java.io.IOException
public void writeInt(int i) throws java.lang.Exception
i
- the int to be written.
java.lang.Exception
public void writeLong(long l) throws java.lang.Exception
l
- the long to be written.
java.lang.Exception
public void writeString(java.lang.String str, int off, int len) throws java.lang.Exception
str
- the String to be written.off
- the offset from the beginning of the String.len
- the number of characters of the String to be written.
java.lang.Exception
public java.lang.String toString()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |