Class SplitOutputStream
- java.lang.Object
-
- java.io.OutputStream
-
- net.lingala.zip4j.io.outputstream.SplitOutputStream
-
- All Implemented Interfaces:
java.io.Closeable,java.io.Flushable,java.lang.AutoCloseable,OutputStreamWithSplitZipSupport
public class SplitOutputStream extends java.io.OutputStream implements OutputStreamWithSplitZipSupport
-
-
Field Summary
Fields Modifier and Type Field Description private longbytesWrittenForThisPartprivate intcurrSplitFileCounterprivate java.io.RandomAccessFilerafprivate RawIOrawIOprivate longsplitLengthprivate java.io.FilezipFile
-
Constructor Summary
Constructors Constructor Description SplitOutputStream(java.io.File file)SplitOutputStream(java.io.File file, long splitLength)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleancheckBufferSizeAndStartNextSplitFile(int bufferSize)Checks if the buffer size is sufficient for the current split file.voidclose()intgetCurrentSplitFileCounter()longgetFilePointer()longgetSplitLength()private booleanisBufferSizeFitForCurrSplitFile(int bufferSize)Checks if the given buffer size will be fit in the current split file.private booleanisHeaderData(byte[] buff)booleanisSplitZipFile()voidseek(long pos)intskipBytes(int n)private voidstartNextSplitFile()voidwrite(byte[] b)voidwrite(byte[] b, int off, int len)voidwrite(int b)
-
-
-
Field Detail
-
raf
private java.io.RandomAccessFile raf
-
splitLength
private long splitLength
-
zipFile
private java.io.File zipFile
-
currSplitFileCounter
private int currSplitFileCounter
-
bytesWrittenForThisPart
private long bytesWrittenForThisPart
-
rawIO
private RawIO rawIO
-
-
Constructor Detail
-
SplitOutputStream
public SplitOutputStream(java.io.File file) throws java.io.FileNotFoundException, ZipException- Throws:
java.io.FileNotFoundExceptionZipException
-
SplitOutputStream
public SplitOutputStream(java.io.File file, long splitLength) throws java.io.FileNotFoundException, ZipException- Throws:
java.io.FileNotFoundExceptionZipException
-
-
Method Detail
-
write
public void write(int b) throws java.io.IOException- Specified by:
writein classjava.io.OutputStream- Throws:
java.io.IOException
-
write
public void write(byte[] b) throws java.io.IOException- Overrides:
writein classjava.io.OutputStream- Throws:
java.io.IOException
-
write
public void write(byte[] b, int off, int len) throws java.io.IOException- Overrides:
writein classjava.io.OutputStream- Throws:
java.io.IOException
-
startNextSplitFile
private void startNextSplitFile() throws java.io.IOException- Throws:
java.io.IOException
-
isHeaderData
private boolean isHeaderData(byte[] buff)
-
checkBufferSizeAndStartNextSplitFile
public boolean checkBufferSizeAndStartNextSplitFile(int bufferSize) throws ZipExceptionChecks if the buffer size is sufficient for the current split file. If not a new split file will be started.- Parameters:
bufferSize-- Returns:
- true if a new split file was started else false
- Throws:
ZipException
-
isBufferSizeFitForCurrSplitFile
private boolean isBufferSizeFitForCurrSplitFile(int bufferSize)
Checks if the given buffer size will be fit in the current split file. If this output stream is a non-split file, then this method always returns true- Parameters:
bufferSize-- Returns:
- true if the buffer size is fit in the current split file or else false.
-
seek
public void seek(long pos) throws java.io.IOException- Throws:
java.io.IOException
-
skipBytes
public int skipBytes(int n) throws java.io.IOException- Throws:
java.io.IOException
-
close
public void close() throws java.io.IOException- Specified by:
closein interfacejava.lang.AutoCloseable- Specified by:
closein interfacejava.io.Closeable- Overrides:
closein classjava.io.OutputStream- Throws:
java.io.IOException
-
getFilePointer
public long getFilePointer() throws java.io.IOException- Specified by:
getFilePointerin interfaceOutputStreamWithSplitZipSupport- Throws:
java.io.IOException
-
isSplitZipFile
public boolean isSplitZipFile()
-
getSplitLength
public long getSplitLength()
-
getCurrentSplitFileCounter
public int getCurrentSplitFileCounter()
- Specified by:
getCurrentSplitFileCounterin interfaceOutputStreamWithSplitZipSupport
-
-