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.
| 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 |
forPaths(java.nio.file.Path... paths)
Concatenates the given file paths.
|
static java.nio.channels.SeekableByteChannel |
forSeekableByteChannels(java.nio.channels.SeekableByteChannel... channels)
Concatenates the given channels.
|
boolean |
isOpen() |
long |
position()
Gets this channel's position.
|
java.nio.channels.SeekableByteChannel |
position(long newPosition) |
java.nio.channels.SeekableByteChannel |
position(long channelNumber,
long relativeOffset)
Sets the position based on the given channel number and relative offset
|
int |
read(java.nio.ByteBuffer dst) |
long |
size() |
java.nio.channels.SeekableByteChannel |
truncate(long size) |
int |
write(java.nio.ByteBuffer src) |
public MultiReadOnlySeekableByteChannel(java.util.List<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 failspublic static java.nio.channels.SeekableByteChannel forPaths(java.nio.file.Path... paths)
throws java.io.IOException
paths - the file paths to concatenate, note that the LAST FILE of files should be the LAST SEGMENT(.zip) and these files should be added in correct
order (e.g.: .z01, .z02... .z99, .zip)java.lang.NullPointerException - if files is nulljava.io.IOException - if opening a channel for one of the files failsjava.io.IOException - if the first channel doesn't seem to hold the beginning of a split archivepublic static java.nio.channels.SeekableByteChannel forSeekableByteChannels(java.nio.channels.SeekableByteChannel... channels)
channels - the channels to concatenatejava.lang.NullPointerException - if channels is nullpublic 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()
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 java.nio.channels.SeekableByteChannelpublic java.nio.channels.SeekableByteChannel position(long newPosition)
throws java.io.IOException
position in interface java.nio.channels.SeekableByteChanneljava.io.IOExceptionpublic java.nio.channels.SeekableByteChannel position(long channelNumber,
long relativeOffset)
throws java.io.IOException
channelNumber - the channel numberrelativeOffset - the relative offset in the corresponding channeljava.io.IOException - if positioning failspublic 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 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.Copyright © 2010 - 2024 Adobe. All Rights Reserved