Class ScatterZipOutputStream
- java.lang.Object
-
- org.apache.commons.compress.archivers.zip.ScatterZipOutputStream
-
- All Implemented Interfaces:
java.io.Closeable
,java.lang.AutoCloseable
public class ScatterZipOutputStream extends java.lang.Object implements java.io.Closeable
A zip output stream that is optimized for multi-threaded scatter/gather construction of zip files.The internal data format of the entries used by this class are entirely private to this class and are not part of any public api whatsoever.
It is possible to extend this class to support different kinds of backing storage, the default implementation only supports file-based backing.
Thread safety: This class supports multiple threads. But the "writeTo" method must be called by the thread that originally created theZipArchiveEntry
.- Since:
- 1.10
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
ScatterZipOutputStream.ZipEntryWriter
-
Constructor Summary
Constructors Constructor Description ScatterZipOutputStream(ScatterGatherBackingStore backingStore, StreamCompressor streamCompressor)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addArchiveEntry(ZipArchiveEntryRequest zipArchiveEntryRequest)
Add an archive entry to this scatter stream.void
close()
Closes this stream, freeing all resources involved in the creation of this stream.static ScatterZipOutputStream
fileBased(java.io.File file)
Create aScatterZipOutputStream
with default compression level that is backed by a filestatic ScatterZipOutputStream
fileBased(java.io.File file, int compressionLevel)
Create aScatterZipOutputStream
that is backed by a filevoid
writeTo(ZipArchiveOutputStream target)
Write the contents of this scatter stream to a target archive.ScatterZipOutputStream.ZipEntryWriter
zipEntryWriter()
Get a zip entry writer for this scatter stream.
-
-
-
Constructor Detail
-
ScatterZipOutputStream
public ScatterZipOutputStream(ScatterGatherBackingStore backingStore, StreamCompressor streamCompressor)
-
-
Method Detail
-
addArchiveEntry
public void addArchiveEntry(ZipArchiveEntryRequest zipArchiveEntryRequest) throws java.io.IOException
Add an archive entry to this scatter stream.- Parameters:
zipArchiveEntryRequest
- The entry to write.- Throws:
java.io.IOException
- If writing fails
-
writeTo
public void writeTo(ZipArchiveOutputStream target) throws java.io.IOException
Write the contents of this scatter stream to a target archive.- Parameters:
target
- The archive to receive the contents of thisScatterZipOutputStream
.- Throws:
java.io.IOException
- If writing fails- See Also:
zipEntryWriter()
-
zipEntryWriter
public ScatterZipOutputStream.ZipEntryWriter zipEntryWriter() throws java.io.IOException
Get a zip entry writer for this scatter stream.- Returns:
- the ZipEntryWriter created on first call of the method
- Throws:
java.io.IOException
- If getting scatter stream input stream
-
close
public void close() throws java.io.IOException
Closes this stream, freeing all resources involved in the creation of this stream.- Specified by:
close
in interfacejava.lang.AutoCloseable
- Specified by:
close
in interfacejava.io.Closeable
- Throws:
java.io.IOException
- If closing fails
-
fileBased
public static ScatterZipOutputStream fileBased(java.io.File file) throws java.io.FileNotFoundException
Create aScatterZipOutputStream
with default compression level that is backed by a file- Parameters:
file
- The file to offload compressed data into.- Returns:
- A ScatterZipOutputStream that is ready for use.
- Throws:
java.io.FileNotFoundException
- if the file cannot be found
-
fileBased
public static ScatterZipOutputStream fileBased(java.io.File file, int compressionLevel) throws java.io.FileNotFoundException
Create aScatterZipOutputStream
that is backed by a file- Parameters:
file
- The file to offload compressed data into.compressionLevel
- The compression level to use, @see #Deflater- Returns:
- A ScatterZipOutputStream that is ready for use.
- Throws:
java.io.FileNotFoundException
- if the file cannot be found
-
-