Class ByteArraySeekableByteChannel

java.lang.Object
org.apache.commons.io.channels.ByteArraySeekableByteChannel
All Implemented Interfaces:
Closeable, AutoCloseable, ByteChannel, Channel, ReadableByteChannel, SeekableByteChannel, WritableByteChannel

A SeekableByteChannel implementation backed by a byte array.

When used for writing, the internal buffer grows to accommodate incoming data. The natural size limit is the value of IOUtils.SOFT_MAX_ARRAY_LENGTH and it's not possible to set the position or truncate to a value bigger than that. The raw internal buffer is accessed via array().

Building a read-only channel from an existing byte array is supported with:


 try (ByteArraySeekableByteChannel channel = ByteArraySeekableByteChannel.builder()
               .setByteArray(...)
               .setOpenOptions(StandardOpenOption.READ)
               .get()) {
               // read from channel
 }
 
Since:
2.21.0