public class ByteBufferByteStreamWriter extends java.lang.Object implements ByteStreamWriter
ByteStreamWriter that writes a java.nio.ByteBuffer to a byte array
parameter.ByteStreamWriter.ByteStreamTarget| Modifier and Type | Field and Description |
|---|---|
private java.nio.ByteBuffer |
buf |
private int |
length |
| Constructor and Description |
|---|
ByteBufferByteStreamWriter(java.nio.ByteBuffer buf)
Construct the writer with the given
ByteBuffer |
| Modifier and Type | Method and Description |
|---|---|
int |
getLength()
Returns the length of the stream.
|
void |
writeTo(ByteStreamWriter.ByteStreamTarget target)
Write the data to the provided
OutputStream. |
public ByteBufferByteStreamWriter(java.nio.ByteBuffer buf)
ByteBufferbuf - the buffer to use.public int getLength()
ByteStreamWriter This must be known ahead of calling ByteStreamWriter.writeTo(ByteStreamTarget).
getLength in interface ByteStreamWriterpublic void writeTo(ByteStreamWriter.ByteStreamTarget target) throws java.io.IOException
ByteStreamWriterOutputStream.
Should not write more than ByteStreamWriter.getLength() bytes. If attempted, the provided stream
will throw an IOException.
writeTo in interface ByteStreamWritertarget - the stream to write the data tojava.io.IOException - if the underlying stream throws or there is some other error.