|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface BitOutput
This interface identifies a sink for bits.
The sink is assumed to have a position which may or may not be at a byte boundary (every eight bits).
If an implementing class also extends OutputStream
it can be
used as an output stream. This interface redefines
OutputStream
's write methods with the extra condition that
they may only be used if the current position of the sink is at a byte
boundary. The writeBytes(byte[], int, int)
method does not have that
limitation.
OutputStream
,
BitInput
Method Summary | |
---|---|
int |
getNumberOfBitsInUnfinishedByte()
Get the number of bits that have been written to the last byte. |
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 interface java.io.Closeable |
---|
close |
Method Detail |
---|
void padToByteBoundary() throws IOException
IOException
- On I/O errors.int getUnfinishedByte()
getNumberOfBitsInUnfinishedByte()
returns how many bit positions
that are used.
If the current position is at a byte boundary, 0 is returned.
int getNumberOfBitsInUnfinishedByte()
If the current position is at a byte boundary, 0 is returned.
void writeBit(boolean val) throws IOException
val
- The bit (true == 1
, false == 0
).
IOException
- On I/O errors.void writeBits(int val, int no) throws IndexOutOfBoundsException, IOException
val
- 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).
IndexOutOfBoundsException
- If no
is less than 0 or greater
than 8.
IOException
- On I/O errorswriteBitsLittleEndian(int, int)
void writeBitsLittleEndian(int val, int no) throws IndexOutOfBoundsException, IOException
val
- 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.writeBits(int, int)
void writeBytes(byte[] barr, int off, int len) throws IndexOutOfBoundsException, IOException
write(byte[], int, int)
, this method does not require that the
current position is at a byte boundary.
barr
- 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 errorswrite(byte[], int, int)
void write(int b) throws IOException
OutputStream.write(int)
.
This method requires that the current position of the output is at a byte boundary.
b
- 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)
void write(byte[] barr) throws IOException
OutputStream.write(byte[])
.
This method requires that the current position of the output is at a byte boundary.
barr
- The bytes to write.
IOException
- On I/O errors or if the current position is not at a
byte boundary.OutputStream.write(byte[])
void write(byte[] barr, int off, int len) throws IndexOutOfBoundsException, IOException
OutputStream.write(byte[], int, int)
.
This method requires that the current position of the output is at a byte boundary.
barr
- 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 errors or if the current position is not at a
byte boundary.OutputStream.write(byte[], int, int)
,
writeBytes(byte[], int, int)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |