BinaryStreams-like helper classes for NIO Channels?

450 views Asked by At

Is there a library for NIO ByteChannel providing similar utilities to what google-guava and commons-io provide for streams? E.g. I'd like to have several ReadableByteChannels concatenated in one or have a view of a channel limited to a particular size.

1

There are 1 answers

2
finnw On

You can partially work around it using the utility methods in the Channels class, e.g.

static byte[] toByteArray(ReadableByteChannel ch) {
    return ByteStreams.toByteArray(Channels.newInputStream(ch));
}