|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object java.io.OutputStream java.io.FilterOutputStream org.freehep.util.io.CompressableOutputStream org.freehep.util.io.BitOutputStream
public class BitOutputStream
Class to write bits to a Stream, allowing for byte synchronization. Signed, Unsigned, Booleans and Floats can be written.
Field Summary |
---|
Fields inherited from class java.io.FilterOutputStream |
---|
out |
Constructor Summary | |
---|---|
BitOutputStream(OutputStream out)
Create a Bit output stream from given stream |
Method Summary | |
---|---|
void |
byteAlign()
A utility to force the next write to be byte-aligned. |
void |
close()
|
void |
finish()
Finishes the current outputstream (compresses, flushes, caluclates CRC) and writes whatever is left in the buffers, but does not close the stream. |
protected void |
flushByte()
A utility method to flush the next byte |
static int |
minBits(float number)
calculates the minumum number of bits necessary to write number. |
static int |
minBits(long number)
|
static int |
minBits(long number,
boolean signed)
|
void |
write(int b)
|
void |
writeBitFlag(boolean bit)
Write a bit to the output stream. |
void |
writeFBits(float value,
int n)
Write a float value of n-bits to the stream. |
void |
writeSBits(long value,
int n)
Write a signed value of n-bits to the output stream. |
void |
writeUBits(long value,
int n)
Write an unsigned value of n-bits to the output stream. |
Methods inherited from class org.freehep.util.io.CompressableOutputStream |
---|
startCompressing, write |
Methods inherited from class java.io.FilterOutputStream |
---|
flush, write |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public BitOutputStream(OutputStream out)
out
- stream to write toMethod Detail |
---|
public void write(int b) throws IOException
write
in class CompressableOutputStream
IOException
public void finish() throws IOException
FinishableOutputStream
finish
in interface FinishableOutputStream
finish
in class CompressableOutputStream
IOException
- if write failspublic void close() throws IOException
close
in interface Closeable
close
in class CompressableOutputStream
IOException
protected void flushByte() throws IOException
IOException
- if write failspublic void byteAlign() throws IOException
IOException
- if write failspublic void writeBitFlag(boolean bit) throws IOException
bit
- value to write
IOException
- if write failspublic void writeSBits(long value, int n) throws IOException
value
- value to writen
- number of bits to write
IOException
- if write failspublic void writeFBits(float value, int n) throws IOException
value
- value to writen
- number of bits to write
IOException
- if write failspublic void writeUBits(long value, int n) throws IOException
value
- value to writen
- number of bits to write
IOException
- if write failspublic static int minBits(float number)
number
- number
public static int minBits(long number)
number
- value to calculate bits for
public static int minBits(long number, boolean signed)
number
- value to calculate bits forsigned
- true if the value if signed (< 0)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |