@NotThreadSafe public final class IntervalReadOnlyChannel extends ReadOnlyChannel
channel| Constructor and Description |
|---|
IntervalReadOnlyChannel(SeekableByteChannel channel,
long size)
Constructs a new interval seekable byte channel starting at the current
position of the file pointer in the decorated seekable byte channel.
|
IntervalReadOnlyChannel(SeekableByteChannel channel,
long start,
long size)
Constructs a new interval seekable byte channel starting at the given
position of the file pointer in the decorated seekable byte channel.
|
| Modifier and Type | Method and Description |
|---|---|
void |
close()
Closes the decorated read only file if and only if it is exclusively
accessed by this decorating read only file.
|
long |
position() |
SeekableByteChannel |
position(long pos) |
int |
read(ByteBuffer dst) |
long |
size() |
truncate, writeisOpen, toStringcheckOpenpublic IntervalReadOnlyChannel(@WillCloseWhenClosed SeekableByteChannel channel, long size) throws IOException
Note that this constructor assumes that it has exclusive access to the decorated seekable byte channel. Concurrent modification of the file pointer in the decorated seekable byte channel may corrupt the input of this decorating seekable byte channel!
channel - the channel to decorate.size - the size of the interval.IOException - on any I/O error.public IntervalReadOnlyChannel(@WillNotClose SeekableByteChannel channel, long start, long size) throws IOException
Note that this constructor assumes that it does not have exclusive access to the decorated seekable byte channel and positions the file pointer in the decorated seekable byte channel before each read operation!
channel - the channel to decorate.start - the start of the interval.size - the size of the interval.IOException - on any I/O error.@DischargesObligation
public void close()
throws IOException
close in interface Closeableclose in interface AutoCloseableclose in interface Channelclose in class DecoratingSeekableChannelIOException - On any I/O error.public long position()
throws IOException
position in interface SeekableByteChannelposition in class DecoratingSeekableChannelIOExceptionpublic SeekableByteChannel position(long pos) throws IOException
position in interface SeekableByteChannelposition in class DecoratingSeekableChannelIOExceptionpublic int read(ByteBuffer dst) throws IOException
read in interface ReadableByteChannelread in interface SeekableByteChannelread in class DecoratingSeekableChannelIOExceptionpublic long size()
throws IOException
size in interface SeekableByteChannelsize in class DecoratingSeekableChannelIOExceptionCopyright © 2012–2014 Schlichtherle IT Services. All rights reserved.