Package org.postgresql.util
Class ByteBufferByteStreamWriter
java.lang.Object
org.postgresql.util.ByteBufferByteStreamWriter
- All Implemented Interfaces:
ByteStreamWriter
A
ByteStreamWriter
that writes a java.nio.ByteBuffer
to a byte array
parameter.-
Nested Class Summary
Nested classes/interfaces inherited from interface org.postgresql.util.ByteStreamWriter
ByteStreamWriter.ByteStreamTarget
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionint
Returns the length of the stream.void
Write the data to the providedOutputStream
.
-
Constructor Details
-
ByteBufferByteStreamWriter
Construct the writer with the givenByteBuffer
- Parameters:
buf
- the buffer to use.
-
-
Method Details
-
getLength
public int getLength()Description copied from interface:ByteStreamWriter
Returns the length of the stream.This must be known ahead of calling
ByteStreamWriter.writeTo(ByteStreamTarget)
.- Specified by:
getLength
in interfaceByteStreamWriter
- Returns:
- the number of bytes in the stream.
-
writeTo
Description copied from interface:ByteStreamWriter
Write the data to the providedOutputStream
.Should not write more than
ByteStreamWriter.getLength()
bytes. If attempted, the provided stream will throw anIOException
.- Specified by:
writeTo
in interfaceByteStreamWriter
- Parameters:
target
- the stream to write the data to- Throws:
IOException
- if the underlying stream throws or there is some other error.
-