@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, write
isOpen, toString
checkOpen
public 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 Closeable
close
in interface AutoCloseable
close
in interface Channel
close
in class DecoratingSeekableChannel
IOException
- On any I/O error.public long position() throws IOException
position
in interface SeekableByteChannel
position
in class DecoratingSeekableChannel
IOException
public SeekableByteChannel position(long pos) throws IOException
position
in interface SeekableByteChannel
position
in class DecoratingSeekableChannel
IOException
public int read(ByteBuffer dst) throws IOException
read
in interface ReadableByteChannel
read
in interface SeekableByteChannel
read
in class DecoratingSeekableChannel
IOException
public long size() throws IOException
size
in interface SeekableByteChannel
size
in class DecoratingSeekableChannel
IOException
Copyright © 2012–2016 Schlichtherle IT Services. All rights reserved.