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 long
bytesWrittenForThisPart
private int
currSplitFileCounter
private java.io.RandomAccessFile
raf
private RawIO
rawIO
private long
splitLength
private java.io.File
zipFile
-
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 boolean
checkBufferSizeAndStartNextSplitFile(int bufferSize)
Checks if the buffer size is sufficient for the current split file.void
close()
int
getCurrentSplitFileCounter()
long
getFilePointer()
long
getSplitLength()
private boolean
isBufferSizeFitForCurrSplitFile(int bufferSize)
Checks if the given buffer size will be fit in the current split file.private boolean
isHeaderData(byte[] buff)
boolean
isSplitZipFile()
void
seek(long pos)
int
skipBytes(int n)
private void
startNextSplitFile()
void
write(byte[] b)
void
write(byte[] b, int off, int len)
void
write(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.FileNotFoundException
ZipException
-
SplitOutputStream
public SplitOutputStream(java.io.File file, long splitLength) throws java.io.FileNotFoundException, ZipException
- Throws:
java.io.FileNotFoundException
ZipException
-
-
Method Detail
-
write
public void write(int b) throws java.io.IOException
- Specified by:
write
in classjava.io.OutputStream
- Throws:
java.io.IOException
-
write
public void write(byte[] b) throws java.io.IOException
- Overrides:
write
in classjava.io.OutputStream
- Throws:
java.io.IOException
-
write
public void write(byte[] b, int off, int len) throws java.io.IOException
- Overrides:
write
in 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 ZipException
Checks 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:
close
in interfacejava.lang.AutoCloseable
- Specified by:
close
in interfacejava.io.Closeable
- Overrides:
close
in classjava.io.OutputStream
- Throws:
java.io.IOException
-
getFilePointer
public long getFilePointer() throws java.io.IOException
- Specified by:
getFilePointer
in interfaceOutputStreamWithSplitZipSupport
- Throws:
java.io.IOException
-
isSplitZipFile
public boolean isSplitZipFile()
-
getSplitLength
public long getSplitLength()
-
getCurrentSplitFileCounter
public int getCurrentSplitFileCounter()
- Specified by:
getCurrentSplitFileCounter
in interfaceOutputStreamWithSplitZipSupport
-
-