Class ZipSplitReadOnlySeekableByteChannel
- java.lang.Object
-
- org.apache.commons.compress.utils.MultiReadOnlySeekableByteChannel
-
- org.apache.commons.compress.archivers.zip.ZipSplitReadOnlySeekableByteChannel
-
- All Implemented Interfaces:
java.io.Closeable,java.lang.AutoCloseable,java.nio.channels.ByteChannel,java.nio.channels.Channel,java.nio.channels.ReadableByteChannel,java.nio.channels.SeekableByteChannel,java.nio.channels.WritableByteChannel
public class ZipSplitReadOnlySeekableByteChannel extends MultiReadOnlySeekableByteChannel
MultiReadOnlySeekableByteChannelthat knows what a split ZIP archive should look like.If you want to read a split archive using
ZipFilethen create an instance of this class from the parts of the archive.- Since:
- 1.20
-
-
Constructor Summary
Constructors Constructor Description ZipSplitReadOnlySeekableByteChannel(java.util.List<java.nio.channels.SeekableByteChannel> channels)Concatenates the given channels.
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static java.nio.channels.SeekableByteChannelbuildFromLastSplitSegment(java.io.File lastSegmentFile)Concatenates ZIP split files from the last segment(the extension SHOULD be .zip)static java.nio.channels.SeekableByteChannelbuildFromLastSplitSegment(java.nio.file.Path lastSegmentPath)Concatenates ZIP split files from the last segment (the extension MUST be .zip)static java.nio.channels.SeekableByteChannelforFiles(java.io.File... files)Concatenates the given files.static java.nio.channels.SeekableByteChannelforFiles(java.io.File lastSegmentFile, java.lang.Iterable<java.io.File> files)Concatenates the given files.static java.nio.channels.SeekableByteChannelforOrderedSeekableByteChannels(java.nio.channels.SeekableByteChannel... channels)Concatenates the given channels.static java.nio.channels.SeekableByteChannelforOrderedSeekableByteChannels(java.nio.channels.SeekableByteChannel lastSegmentChannel, java.lang.Iterable<java.nio.channels.SeekableByteChannel> channels)Concatenates the given channels.static java.nio.channels.SeekableByteChannelforPaths(java.nio.file.Path... paths)Concatenates the given file paths.static java.nio.channels.SeekableByteChannelforPaths(java.nio.file.Path lastSegmentPath, java.lang.Iterable<java.nio.file.Path> paths)Concatenates the given file paths.static java.nio.channels.SeekableByteChannelforPaths(java.util.List<java.nio.file.Path> paths, java.nio.file.OpenOption[] openOptions)Concatenates the given file paths.
-
-
-
Constructor Detail
-
ZipSplitReadOnlySeekableByteChannel
public ZipSplitReadOnlySeekableByteChannel(java.util.List<java.nio.channels.SeekableByteChannel> channels) throws java.io.IOExceptionConcatenates the given channels.The channels should be add in ascending order, e.g. z01, z02, ... z99, ZIP please note that the .zip file is the last segment and should be added as the last one in the channels
- Parameters:
channels- the channels to concatenate- Throws:
java.lang.NullPointerException- if channels is nulljava.io.IOException- if the first channel doesn't seem to hold the beginning of a split archive
-
-
Method Detail
-
buildFromLastSplitSegment
public static java.nio.channels.SeekableByteChannel buildFromLastSplitSegment(java.io.File lastSegmentFile) throws java.io.IOExceptionConcatenates ZIP split files from the last segment(the extension SHOULD be .zip)- Parameters:
lastSegmentFile- the last segment of ZIP split files, note that the extension SHOULD be .zip- Returns:
- SeekableByteChannel that concatenates all ZIP split files
- Throws:
java.lang.IllegalArgumentException- if the lastSegmentFile's extension is NOT .zipjava.io.IOException- if the first channel doesn't seem to hold the beginning of a split archive
-
buildFromLastSplitSegment
public static java.nio.channels.SeekableByteChannel buildFromLastSplitSegment(java.nio.file.Path lastSegmentPath) throws java.io.IOExceptionConcatenates ZIP split files from the last segment (the extension MUST be .zip)- Parameters:
lastSegmentPath- the last segment of ZIP split files, note that the extension MUST be .zip- Returns:
- SeekableByteChannel that concatenates all ZIP split files
- Throws:
java.lang.IllegalArgumentException- if the lastSegmentPath's extension is NOT .zipjava.io.IOException- if the first channel doesn't seem to hold the beginning of a split archive- Since:
- 1.22
-
forFiles
public static java.nio.channels.SeekableByteChannel forFiles(java.io.File... files) throws java.io.IOExceptionConcatenates the given files.- Parameters:
files- the files 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)- Returns:
- SeekableByteChannel that concatenates all provided files
- Throws:
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 archive
-
forFiles
public static java.nio.channels.SeekableByteChannel forFiles(java.io.File lastSegmentFile, java.lang.Iterable<java.io.File> files) throws java.io.IOExceptionConcatenates the given files.- Parameters:
lastSegmentFile- the last segment of split ZIP segments, its extension should be .zipfiles- the files to concatenate except for the last segment, note these files should be added in correct order (e.g. .z01, .z02... .z99)- Returns:
- SeekableByteChannel that concatenates all provided files
- Throws:
java.io.IOException- if the first channel doesn't seem to hold the beginning of a split archivejava.lang.NullPointerException- if files or lastSegmentFile is null
-
forOrderedSeekableByteChannels
public static java.nio.channels.SeekableByteChannel forOrderedSeekableByteChannels(java.nio.channels.SeekableByteChannel... channels) throws java.io.IOExceptionConcatenates the given channels.- Parameters:
channels- the channels to concatenate, note that the LAST CHANNEL of channels should be the LAST SEGMENT(.zip) and these channels should be added in correct order (e.g. .z01, .z02... .z99, .zip)- Returns:
- SeekableByteChannel that concatenates all provided channels
- Throws:
java.lang.NullPointerException- if channels is nulljava.io.IOException- if reading channels fails
-
forOrderedSeekableByteChannels
public static java.nio.channels.SeekableByteChannel forOrderedSeekableByteChannels(java.nio.channels.SeekableByteChannel lastSegmentChannel, java.lang.Iterable<java.nio.channels.SeekableByteChannel> channels) throws java.io.IOExceptionConcatenates the given channels.- Parameters:
lastSegmentChannel- channel of the last segment of split ZIP segments, its extension should be .zipchannels- the channels to concatenate except for the last segment, note these channels should be added in correct order (e.g. .z01, .z02... .z99)- Returns:
- SeekableByteChannel that concatenates all provided channels
- Throws:
java.lang.NullPointerException- if lastSegmentChannel or channels is nulljava.io.IOException- if the first channel doesn't seem to hold the beginning of a split archive
-
forPaths
public static java.nio.channels.SeekableByteChannel forPaths(java.util.List<java.nio.file.Path> paths, java.nio.file.OpenOption[] openOptions) throws java.io.IOExceptionConcatenates the given file paths.- Parameters:
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)openOptions- the options to open paths (shared by all paths).- Returns:
- SeekableByteChannel that concatenates all provided files
- Throws:
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 archive- Since:
- 1.22
-
forPaths
public static java.nio.channels.SeekableByteChannel forPaths(java.nio.file.Path... paths) throws java.io.IOExceptionConcatenates the given file paths.- Parameters:
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)- Returns:
- SeekableByteChannel that concatenates all provided files
- Throws:
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 archive- Since:
- 1.22
-
forPaths
public static java.nio.channels.SeekableByteChannel forPaths(java.nio.file.Path lastSegmentPath, java.lang.Iterable<java.nio.file.Path> paths) throws java.io.IOExceptionConcatenates the given file paths.- Parameters:
lastSegmentPath- the last segment path of split ZIP segments, its extension must be .zippaths- the file paths to concatenate except for the last segment, note these files should be added in correct order (e.g.: .z01, .z02... .z99)- Returns:
- SeekableByteChannel that concatenates all provided files
- Throws:
java.io.IOException- if the first channel doesn't seem to hold the beginning of a split archivejava.lang.NullPointerException- if files or lastSegmentPath is null- Since:
- 1.22
-
-