|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object java.io.OutputStream PIRL.Utilities.ByteBuffer_OutputStream
public class ByteBuffer_OutputStream
A ByteBuffer_OutputStream presents a ByteBuffer as an OutputStream.
This class is thread safe: Methods that might modify the backing ByteBuffer are synchronized on the ByteBuffer.
ByteBuffer
,
OutputStream
Field Summary | |
---|---|
static String |
ID
Class identification name with source code version and date. |
Constructor Summary | |
---|---|
ByteBuffer_OutputStream(ByteBuffer destination)
Construct a ByteBuffer_OutputStream on a ByteBuffer. |
Method Summary | |
---|---|
int |
available()
Get the amount of storage space remaining in the destination. |
ByteBuffer |
Destination()
Get the ByteBuffer backing this ByteBuffer_OutputStream. |
void |
write(byte[] byte_array)
Put the contents of a byte array into the destination. |
void |
write(byte[] byte_array,
int offset,
int amount)
Put some number of bytes from a byte array into the destination. |
void |
write(int datum)
Put the datum at the next position in the destination. |
Methods inherited from class java.io.OutputStream |
---|
close, flush |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final String ID
Constructor Detail |
---|
public ByteBuffer_OutputStream(ByteBuffer destination)
destination
- The ByteBuffer to be used as the destination of
output data.
NullPointerException
- If the destination is null.Method Detail |
---|
public ByteBuffer Destination()
public int available()
destination
. This is the difference between the buffer's
current output position
and the output
limit
. Note that the limit may be less
than the buffer capacity
.public void write(int datum) throws EOFException
The operation is synchronized on the destination buffer.
write
in class OutputStream
EOFExcetption
- If the destination is full; i.e. the output
position is at its limit.
EOFException
available()
public void write(byte[] byte_array) throws EOFException
This method simply uses
write (byte_array, 0, byte_array.length)
.
write
in class OutputStream
byte_array
- A byte[] array containing the data to be stored
in the destination buffer.
NullPointerException
- If the byte array is null.
EOFExcetption
- If the destination is full; i.e. the output
position is at its limit.
EOFException
write(byte[], int, int)
,
available()
public void write(byte[] byte_array, int offset, int amount) throws EOFException
If the amount to write is less than or equal to zero nothing is done. The amount specified to write must be no greater than the number of bytes in the array after the offset nor the space remaining in the destination buffer.
The operation is synchronized on the destination buffer.
write
in class OutputStream
byte_array
- A byte[] array containing data to be transferred.offset
- The index of the array containing the first byte to be
transferred.amount
- The maximum number of bytes to transfer from the array
to the destination
.
NullPointerException
- If the byte array is null.
IndexOutOfBoundsException
- If the offset is negative or
the offset plus the amount is greater than the remaining bytes
in the array.
EOFExcetption
- If the space available
in the destination is less than the amount of data specified to
transfer.
EOFException
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |