public class MultiReadOnlySeekableByteChannel
extends java.lang.Object
implements java.nio.channels.SeekableByteChannel
SeekableByteChannel that
concatenates a collection of other SeekableByteChannels.
This is a lose port of MultiReadOnlySeekableByteChannel by Tim Underwood.
| Modifier and Type | Field and Description |
|---|---|
private java.util.List<java.nio.channels.SeekableByteChannel> |
channels |
private int |
currentChannelIdx |
private long |
globalPosition |
| Constructor and Description |
|---|
MultiReadOnlySeekableByteChannel(java.util.List<java.nio.channels.SeekableByteChannel> channels)
Concatenates the given channels.
|
| Modifier and Type | Method and Description |
|---|---|
void |
close() |
static java.nio.channels.SeekableByteChannel |
forFiles(java.io.File... files)
Concatenates the given files.
|
static java.nio.channels.SeekableByteChannel |
forSeekableByteChannels(java.nio.channels.SeekableByteChannel... channels)
Concatenates the given channels.
|
boolean |
isOpen() |
long |
position() |
java.nio.channels.SeekableByteChannel |
position(long newPosition) |
int |
read(java.nio.ByteBuffer dst) |
long |
size() |
java.nio.channels.SeekableByteChannel |
truncate(long size) |
int |
write(java.nio.ByteBuffer src) |
private final java.util.List<java.nio.channels.SeekableByteChannel> channels
private long globalPosition
private int currentChannelIdx
public MultiReadOnlySeekableByteChannel(java.util.List<java.nio.channels.SeekableByteChannel> channels)
channels - the channels to concatenatejava.lang.NullPointerException - if channels is nullpublic int read(java.nio.ByteBuffer dst)
throws java.io.IOException
read in interface java.nio.channels.ReadableByteChannelread in interface java.nio.channels.SeekableByteChanneljava.io.IOExceptionpublic void close()
throws java.io.IOException
close in interface java.io.Closeableclose in interface java.lang.AutoCloseableclose in interface java.nio.channels.Channeljava.io.IOExceptionpublic boolean isOpen()
isOpen in interface java.nio.channels.Channelpublic long position()
position in interface java.nio.channels.SeekableByteChannelpublic long size()
throws java.io.IOException
size in interface java.nio.channels.SeekableByteChanneljava.io.IOExceptionpublic java.nio.channels.SeekableByteChannel truncate(long size)
truncate in interface java.nio.channels.SeekableByteChanneljava.nio.channels.NonWritableChannelException - since this implementation is read-only.public int write(java.nio.ByteBuffer src)
write in interface java.nio.channels.SeekableByteChannelwrite in interface java.nio.channels.WritableByteChanneljava.nio.channels.NonWritableChannelException - since this implementation is read-only.public java.nio.channels.SeekableByteChannel position(long newPosition)
throws java.io.IOException
position in interface java.nio.channels.SeekableByteChanneljava.io.IOExceptionpublic static java.nio.channels.SeekableByteChannel forSeekableByteChannels(java.nio.channels.SeekableByteChannel... channels)
channels - the channels to concatenatejava.lang.NullPointerException - if channels is nullpublic static java.nio.channels.SeekableByteChannel forFiles(java.io.File... files)
throws java.io.IOException
files - the files to concatenatejava.lang.NullPointerException - if files is nulljava.io.IOException - if opening a channel for one of the files fails