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
Constructors -
Method Summary
Modifier and TypeMethodDescriptionintReturns the length of the stream.voidWrite 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:ByteStreamWriterReturns the length of the stream.This must be known ahead of calling
ByteStreamWriter.writeTo(ByteStreamTarget).- Specified by:
getLengthin interfaceByteStreamWriter- Returns:
- the number of bytes in the stream.
-
writeTo
Description copied from interface:ByteStreamWriterWrite the data to the providedOutputStream.Should not write more than
ByteStreamWriter.getLength()bytes. If attempted, the provided stream will throw anIOException.- Specified by:
writeToin interfaceByteStreamWriter- Parameters:
target- the stream to write the data to- Throws:
IOException- if the underlying stream throws or there is some other error.
-