Package org.postgresql.util
Class ByteBufferByteStreamWriter
- java.lang.Object
-
- org.postgresql.util.ByteBufferByteStreamWriter
-
- All Implemented Interfaces:
ByteStreamWriter
public class ByteBufferByteStreamWriter extends java.lang.Object implements ByteStreamWriter
AByteStreamWriter
that writes ajava.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 Constructor Description ByteBufferByteStreamWriter(java.nio.ByteBuffer buf)
Construct the writer with the givenByteBuffer
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int
getLength()
Returns the length of the stream.void
writeTo(ByteStreamWriter.ByteStreamTarget target)
Write the data to the providedOutputStream
.
-
-
-
Method Detail
-
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
public void writeTo(ByteStreamWriter.ByteStreamTarget target) throws java.io.IOException
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:
java.io.IOException
- if the underlying stream throws or there is some other error.
-
-