Package org.postgresql.util

# Class ByteBufferByteStreamWriter

java.lang.Object
org.postgresql.util.ByteBufferByteStreamWriter

All Implemented Interfaces:
  `ByteStreamWriter`

public class ByteBufferByteStreamWriter extends Object implements 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
Constructor
Description
`ByteBufferByteStreamWriter(ByteBuffer buf)`
Construct the writer with the given `ByteBuffer`

## Method Summary

Modifier and Type
Method
Description
`int`
`getLength()`
Returns the length of the stream.
`void`
`writeTo(ByteStreamWriter.ByteStreamTarget target)`
Write the data to the provided `OutputStream`.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Constructor Details

### ByteBufferByteStreamWriter

public ByteBufferByteStreamWriter(ByteBuffer buf)
Construct the writer with the given `ByteBuffer`

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 interface `ByteStreamWriter`
Returns:
  the number of bytes in the stream.

### writeTo

public void writeTo(ByteStreamWriter.ByteStreamTarget target) throws IOException
Description copied from interface: `ByteStreamWriter`
Write the data to the provided `OutputStream`.

Should not write more than `ByteStreamWriter.getLength()` bytes. If attempted, the provided stream will throw an `IOException`.

Specified by:
  `writeTo` in interface `ByteStreamWriter`
Parameters:
  `target` - the stream to write the data to
Throws:
  `IOException` - if the underlying stream throws or there is some other error.