public final class RewindableReadableByteChannel extends Object implements ReadableByteChannel
ReadableByteChannel that provides rewinding feature: it caches the read
bytes so that after reading some initial part of the channel, one can "rewind" the channel and
again read the bytes from the beginning. Once the rewinding feature is not needed any more, it
can be disabled via disableRewinding(): this frees the cache memory and forwadrds the
subsequent read(java.nio.ByteBuffer)-calls directly to the wrapped channel.| Constructor and Description |
|---|
RewindableReadableByteChannel(ReadableByteChannel baseChannel)
Constructs a wrapper around
baseChannel. |
| Modifier and Type | Method and Description |
|---|---|
void |
close() |
void |
disableRewinding()
Disables the rewinding feature.
|
boolean |
isOpen() |
int |
read(ByteBuffer dst) |
void |
rewind()
Rewinds this buffer to the beginning (if rewinding is still enabled).
|
public RewindableReadableByteChannel(ReadableByteChannel baseChannel)
baseChannel.
After wrapping baseChannel should not be manipulated externally.public void disableRewinding()
public void rewind()
throws IOException
IOExceptionpublic int read(ByteBuffer dst) throws IOException
read in interface ReadableByteChannelIOExceptionpublic void close()
throws IOException
close in interface Closeableclose in interface AutoCloseableclose in interface ChannelIOException