public class MultiReadOnlySeekableByteChannel extends Object implements SeekableByteChannel
SeekableByteChannel that
concatenates a collection of other SeekableByteChannels.
This is a lose port of MultiReadOnlySeekableByteChannel by Tim Underwood.
| Constructor and Description |
|---|
MultiReadOnlySeekableByteChannel(List<SeekableByteChannel> channels)
Concatenates the given channels.
|
| Modifier and Type | Method and Description |
|---|---|
void |
close() |
static SeekableByteChannel |
forFiles(File... files)
Concatenates the given files.
|
static SeekableByteChannel |
forSeekableByteChannels(SeekableByteChannel... channels)
Concatenates the given channels.
|
boolean |
isOpen() |
long |
position()
Returns this channel's position.
|
SeekableByteChannel |
position(long newPosition) |
SeekableByteChannel |
position(long channelNumber,
long relativeOffset)
set the position based on the given channel number and relative offset
|
int |
read(ByteBuffer dst) |
long |
size() |
SeekableByteChannel |
truncate(long size) |
int |
write(ByteBuffer src) |
public MultiReadOnlySeekableByteChannel(List<SeekableByteChannel> channels)
channels - the channels to concatenateNullPointerException - if channels is nullpublic int read(ByteBuffer dst) throws IOException
read in interface ReadableByteChannelread in interface SeekableByteChannelIOExceptionpublic void close() throws IOException
close in interface Closeableclose in interface AutoCloseableclose in interface ChannelIOExceptionpublic long position()
This method violates the contract of SeekableByteChannel.position() as it will not throw any exception
when invoked on a closed channel. Instead it will return the position the channel had when close has been
called.
position in interface SeekableByteChannelpublic SeekableByteChannel position(long channelNumber, long relativeOffset) throws IOException
channelNumber - the channel numberrelativeOffset - the relative offset in the corresponding channelIOException - if positioning failspublic long size() throws IOException
size in interface SeekableByteChannelIOExceptionpublic SeekableByteChannel truncate(long size)
truncate in interface SeekableByteChannelNonWritableChannelException - since this implementation is read-only.public int write(ByteBuffer src)
write in interface SeekableByteChannelwrite in interface WritableByteChannelNonWritableChannelException - since this implementation is read-only.public SeekableByteChannel position(long newPosition) throws IOException
position in interface SeekableByteChannelIOExceptionpublic static SeekableByteChannel forSeekableByteChannels(SeekableByteChannel... channels)
channels - the channels to concatenateNullPointerException - if channels is nullpublic static SeekableByteChannel forFiles(File... files) throws IOException
files - the files to concatenateNullPointerException - if files is nullIOException - if opening a channel for one of the files failsCopyright © 2002–2020 The Apache Software Foundation. All rights reserved.