class ZipSplitOutputStream
extends java.io.OutputStream
ZipArchiveOutputStream
when creating a split archive.Modifier and Type | Field and Description |
---|---|
private long |
currentSplitSegmentBytesWritten |
private int |
currentSplitSegmentIndex |
private boolean |
finished |
private java.io.OutputStream |
outputStream |
private byte[] |
singleByte |
private long |
splitSize |
private static long |
ZIP_SEGMENT_MAX_SIZE |
private static long |
ZIP_SEGMENT_MIN_SIZE
8.5.1 Capacities for split archives are as follows:
|
private java.io.File |
zipFile |
Constructor and Description |
---|
ZipSplitOutputStream(java.io.File zipFile,
long splitSize)
Create a split zip.
|
Modifier and Type | Method and Description |
---|---|
void |
close() |
private java.io.File |
createNewSplitSegmentFile(java.lang.Integer zipSplitSegmentSuffixIndex)
Create the new zip split segment, the last zip segment should be .zip, and the zip split segments' suffix should be
like .z01, .z02, .z03, ...
|
private void |
finish()
The last zip split segment's suffix should be .zip
|
long |
getCurrentSplitSegmentBytesWritten() |
int |
getCurrentSplitSegmentIndex() |
private java.io.OutputStream |
openNewSplitSegment()
Create a new zip split segment and prepare to write to the new segment
|
void |
prepareToWriteUnsplittableContent(long unsplittableContentSize)
Some data can not be written to different split segments, for example:
|
void |
write(byte[] b) |
void |
write(byte[] b,
int off,
int len)
Write the data to zip split segments, if the remaining space of current split segment
is not enough, then a new split segment should be created
|
void |
write(int i) |
private void |
writeZipSplitSignature()
Write the zip split signature (0x08074B50) to the head of the first zip split segment
|
private java.io.OutputStream outputStream
private java.io.File zipFile
private final long splitSize
private int currentSplitSegmentIndex
private long currentSplitSegmentBytesWritten
private boolean finished
private final byte[] singleByte
private static final long ZIP_SEGMENT_MIN_SIZE
Maximum number of segments = 4,294,967,295 - 1 Maximum .ZIP segment size = 4,294,967,295 bytes (refer to section 8.5.6) Minimum segment size = 64K Maximum PKSFX segment size = 2,147,483,647 bytes
private static final long ZIP_SEGMENT_MAX_SIZE
public ZipSplitOutputStream(java.io.File zipFile, long splitSize) throws java.lang.IllegalArgumentException, java.io.IOException
zipFile
- the zip file to write tosplitSize
- the split sizejava.lang.IllegalArgumentException
java.io.IOException
public void prepareToWriteUnsplittableContent(long unsplittableContentSize) throws java.lang.IllegalArgumentException, java.io.IOException
4.4.1.5 The end of central directory record and the Zip64 end of central directory locator record MUST reside on the same disk when splitting or spanning an archive.
unsplittableContentSize
- java.lang.IllegalArgumentException
java.io.IOException
public void write(int i) throws java.io.IOException
write
in class java.io.OutputStream
java.io.IOException
public void write(byte[] b) throws java.io.IOException
write
in class java.io.OutputStream
java.io.IOException
public void write(byte[] b, int off, int len) throws java.io.IOException
write
in class java.io.OutputStream
b
- data to writeoff
- offset of the start of data in param blen
- the length of data to writejava.io.IOException
public void close() throws java.io.IOException
close
in interface java.io.Closeable
close
in interface java.lang.AutoCloseable
close
in class java.io.OutputStream
java.io.IOException
private void finish() throws java.io.IOException
java.io.IOException
private java.io.OutputStream openNewSplitSegment() throws java.io.IOException
java.io.IOException
private void writeZipSplitSignature() throws java.io.IOException
java.io.IOException
private java.io.File createNewSplitSegmentFile(java.lang.Integer zipSplitSegmentSuffixIndex) throws java.io.IOException
8.3.3 Split ZIP files are typically written to the same location and are subject to name collisions if the spanned name format is used since each segment will reside on the same drive. To avoid name collisions, split archives are named as follows.
Segment 1 = filename.z01 Segment n-1 = filename.z(n-1) Segment n = filename.zip
NOTE: The zip split segment begin from 1,2,3,... , and we're creating a new segment, so the new segment suffix should be (currentSplitSegmentIndex + 2)
zipSplitSegmentSuffixIndex
- java.io.IOException
public int getCurrentSplitSegmentIndex()
public long getCurrentSplitSegmentBytesWritten()