Class StorageChannelUtils (2.56.0)

public final class StorageChannelUtils

Set of utility methods for working with non-blocking channels returned by this library.

Inheritance

java.lang.Object > StorageChannelUtils

Static Methods

blockingEmptyTo(ByteBuffer buf, WritableByteChannel c)

public static int blockingEmptyTo(ByteBuffer buf, WritableByteChannel c)

Attempt to empty buf to c, blocking the invoking thread if necessary in order to do so.

This method will not close c

Parameters
Name Description
buf ByteBuffer
c WritableByteChannel
Returns
Type Description
int

The number of bytes written, possibly zero

Exceptions
Type Description
IOException

any IOException from calling WritableByteChannel#write(ByteBuffer)

blockingFillFrom(ByteBuffer buf, ReadableByteChannel c)

public static int blockingFillFrom(ByteBuffer buf, ReadableByteChannel c)

Attempt to fill buf from c, blocking the invoking thread if necessary in order to do so.

This method will not close c.

Parameters
Name Description
buf ByteBuffer
c ReadableByteChannel
Returns
Type Description
int

The number of bytes read, possibly zero, or -1 if the channel has reached end-of-stream

Exceptions
Type Description
IOException

any IOException from calling ReadableByteChannel#read(ByteBuffer)