JVM | Platform | Status |
---|---|---|
OpenJDK (Temurin) Current | Linux | |
OpenJDK (Temurin) LTS | Linux | |
OpenJDK (Temurin) Current | Windows | |
OpenJDK (Temurin) LTS | Windows |
The wendover
package provides extra classes for working with Java NIO
channels.
- Numerous
Channel
classes and adapters with various properties. - High coverage test suite.
- OSGi-ready.
- JPMS-ready.
- ISC license.
Use CloseShieldSeekableByteChannel
in order to prevent external code from
closing an arbitrary SeekableByteChannel
instance:
SeekableByteChannel c;
someUntrustedObject.run(new CloseShieldSeekableByteChannel(c));
The CloseShieldSeekableByteChannel
instance can be closed, but will not
result in the underlying channel really being closed.
Use ReadOnlySeekableByteChannel
to protect an arbitrary SeekableByteChannel
instance against writes:
SeekableByteChannel c;
someUntrustedObject.run(new ReadOnlySeekableByteChannel(c));
Attempts to write to the ReadOnlySeekableByteChannel
will result in
NonWritableChannelException
being thrown.
Use SubrangeSeekableByteChannel
to restrict reads and writes to an arbitrary
SeekableByteChannel
instance to a particular range:
SeekableByteChannel c;
someObject.run(new SubrangeSeekableByteChannel(c, 100L, 1000L));
Reads of the SubrangeSeekableByteChannel
instance will be limited to only
reading data that falls within offsets [100, 100 + 1000 - 1]
. Reading at
position 0
of the SubrangeSeekableByteChannel
instance will actually
read from position 100
of c
. Writes are similarly translated and limited.
Use UpperRangeTrackingSeekableByteChannel
to track the uppermost point
written by an arbitrary SeekableByteChannel
instance:
SeekableByteChannel c;
var d = new UpperRangeTrackingSeekableByteChannel(c);
someObject.run(d);
System.out.println(d.uppermostWritten());
Use the ByteBufferChannels
class to adapt a ByteBuffer
into a
SeekableByteChannel
:
ByteBuffer data;
SeekableByteChannel c = ByteBufferChannels.ofByteBuffer(data);
Use the DelegatingSeekableByteChannel
class to delegate operations to an
existing channel. This class is used to implement most of the wendover
package.