|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectjava.io.OutputStream
org.at4j.support.io.LittleEndianBitOutputStream
public class LittleEndianBitOutputStream
This is an OutputStream that implements BitOutput and hence
can be used to write individual bits to the output. The bits are stored in
little-endian order.
| Constructor Summary | |
|---|---|
LittleEndianBitOutputStream(OutputStream wrapped)
|
|
| Method Summary | |
|---|---|
void |
close()
Close the output stream. |
int |
getNumberOfBitsInUnfinishedByte()
Get the number of bits that have been written to the last byte. |
long |
getNumberOfBytesWritten()
Get the total number of whole bytes written by this stream so far. |
int |
getUnfinishedByte()
Get the value of the unfinished byte. |
void |
padToByteBoundary()
Pad the output with zeroes to the next byte boundary. |
void |
write(byte[] barr)
See OutputStream.write(byte[]). |
void |
write(byte[] barr,
int off,
int len)
See OutputStream.write(byte[], int, int). |
void |
write(int b)
See OutputStream.write(int). |
void |
writeBit(boolean val)
Write a single bit. |
void |
writeBits(int val,
int no)
Write up to eight bits. |
void |
writeBitsLittleEndian(int val,
int no)
Write up to 32 bits. |
void |
writeBytes(byte[] barr,
int off,
int len)
Write an array of bytes to the output. |
| Methods inherited from class java.io.OutputStream |
|---|
flush |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public LittleEndianBitOutputStream(OutputStream wrapped)
| Method Detail |
|---|
public long getNumberOfBytesWritten()
public int getUnfinishedByte()
BitOutputBitOutput.getNumberOfBitsInUnfinishedByte() returns how many bit positions
that are used.
If the current position is at a byte boundary, 0 is returned.
getUnfinishedByte in interface BitOutputpublic int getNumberOfBitsInUnfinishedByte()
BitOutputIf the current position is at a byte boundary, 0 is returned.
getNumberOfBitsInUnfinishedByte in interface BitOutput
public void padToByteBoundary()
throws IOException
BitOutput
padToByteBoundary in interface BitOutputIOException - On I/O errors.
public void writeBit(boolean val)
throws IOException
BitOutput
writeBit in interface BitOutputval - The bit (true == 1, false == 0).
IOException - On I/O errors.
public void writeBits(int val,
int no)
throws IOException,
IndexOutOfBoundsException
BitOutput
writeBits in interface BitOutputval - The value to write. The bits written are the no
rightmost bits of val. It is not verified that val fits
within its no rightmost bits. If it does not, the written value
is simply truncated.no - The number of bits to write. This must be between 0 and 8
(inclusive).
IOException - On I/O errors
IndexOutOfBoundsException - If no is less than 0 or greater
than 8.BitOutput.writeBitsLittleEndian(int, int)
public void writeBitsLittleEndian(int val,
int no)
throws IndexOutOfBoundsException,
IOException
BitOutput
writeBitsLittleEndian in interface BitOutputval - The value to write. The bits written are the no
rightmost bits of val. It is not verified that val fits
within its no rightmost bits. If it does not, the written value
is simply truncated.no - The number of bits to write. This must be between 0 and 32
(inclusive)
IndexOutOfBoundsException - If no is less than 0 or more
than 32.
IOException - On I/O errors.BitOutput.writeBits(int, int)
public void writeBytes(byte[] barr,
int off,
int len)
throws IndexOutOfBoundsException,
IOException
BitOutputBitOutput.write(byte[], int, int), this method does not require that the
current position is at a byte boundary.
writeBytes in interface BitOutputbarr - The bytes to write.off - The offset in the byte array.len - The number of bytes to write.
IndexOutOfBoundsException - If the offset or the length is negative
or if the offset + length is larger than the byte array.
IOException - On I/O errorsBitOutput.write(byte[], int, int)
public void write(int b)
throws IOException
BitOutputOutputStream.write(int).
This method requires that the current position of the output is at a byte boundary.
write in interface BitOutputwrite in class OutputStreamb - The byte to write (0 - 255).
IOException - On I/O errors or if the current position is not at a
byte boundary.OutputStream.write(int)
public void write(byte[] barr)
throws IOException
BitOutputOutputStream.write(byte[]).
This method requires that the current position of the output is at a byte boundary.
write in interface BitOutputwrite in class OutputStreambarr - The bytes to write.
IOException - On I/O errors or if the current position is not at a
byte boundary.OutputStream.write(byte[])
public void write(byte[] barr,
int off,
int len)
throws IOException
BitOutputOutputStream.write(byte[], int, int).
This method requires that the current position of the output is at a byte boundary.
write in interface BitOutputwrite in class OutputStreambarr - The bytes to write.off - The offset in the byte array.len - The number of bytes to write.
IOException - On I/O errors or if the current position is not at a
byte boundary.OutputStream.write(byte[], int, int),
BitOutput.writeBytes(byte[], int, int)
public void close()
throws IOException
This method does not automatically pad the last written bits to a full
byte. If there are bits written to it the stream must be padded before
closing it. See padToByteBoundary().
close in interface Closeableclose in class OutputStreamIOException
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||