com.ibm.jzos
Class ZCompressorOutputStream
- java.lang.Object
-
- java.io.OutputStream
-
- java.io.FilterOutputStream
-
- com.ibm.jzos.ZCompressorOutputStream
-
- All Implemented Interfaces:
- java.io.Closeable, java.io.Flushable, java.lang.AutoCloseable
public class ZCompressorOutputStream extends java.io.FilterOutputStreamA subclass ofOutputStreamthat will compress data as it writes to another OutputStream. Not thread safe.- Since:
- 2.4.4
- See Also:
ZCompressor
-
-
Constructor Summary
Constructors Constructor and Description ZCompressorOutputStream(ZCompressor compressor, java.io.OutputStream out)Create a new output stream with default buffer size.ZCompressorOutputStream(ZCompressor compressor, java.io.OutputStream out, int buflen)Create a new output stream with the specified buffer size.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method and Description voidclose()This method also flushes data, including any partially compressed last byte.voidflush()This flushes the buffer of all compressed data, excluding a possible partial last byte.longgetTotalCompressedBytes()Answer the total number of compressed bytes written so far.longgetTotalSourceBytes()Answer the total number of input (uncompressed) bytes written so far.voidreleaseZCompressorOnClose(boolean value)Sets a flag that will cause the ZCompressor resources to be released when this OutputStream is closed.voidwrite(byte[] b, int off, int len)voidwrite(int b)
-
-
-
Constructor Detail
-
ZCompressorOutputStream
public ZCompressorOutputStream(ZCompressor compressor, java.io.OutputStream out)
Create a new output stream with default buffer size.- Parameters:
compressor- the ZCompressor object used to compress dataout- the target OutputStream for compressed data
-
ZCompressorOutputStream
public ZCompressorOutputStream(ZCompressor compressor, java.io.OutputStream out, int buflen)
Create a new output stream with the specified buffer size.- Parameters:
compressor- the ZCompressor object used to compress dataout- the target OutputStream for compressed databuflen- internal buffer for compressed data
-
-
Method Detail
-
releaseZCompressorOnClose
public void releaseZCompressorOnClose(boolean value)
Sets a flag that will cause the ZCompressor resources to be released when this OutputStream is closed. Defaults tofalse.
-
getTotalSourceBytes
public long getTotalSourceBytes()
Answer the total number of input (uncompressed) bytes written so far.- Returns:
- the total number of input (uncompressed) bytes written
-
getTotalCompressedBytes
public long getTotalCompressedBytes()
Answer the total number of compressed bytes written so far.- Returns:
- the total number of compressed bytes written
-
write
public void write(byte[] b, int off, int len) throws java.io.IOException- Overrides:
writein classjava.io.FilterOutputStream- Throws:
java.io.IOException- See Also:
OutputStream.write(byte[], int, int)
-
write
public void write(int b) throws java.io.IOException- Overrides:
writein classjava.io.FilterOutputStream- Throws:
java.io.IOException- See Also:
OutputStream.write(int)
-
close
public void close() throws java.io.IOExceptionThis method also flushes data, including any partially compressed last byte.- Specified by:
closein interfacejava.io.Closeable- Specified by:
closein interfacejava.lang.AutoCloseable- Overrides:
closein classjava.io.FilterOutputStream- Throws:
java.io.IOException- See Also:
OutputStream.close()
-
flush
public void flush() throws java.io.IOExceptionThis flushes the buffer of all compressed data, excluding a possible partial last byte. Remaining unused bits in such a partial byte may be used for compressing more data, and is only written when the stream is closed.- Specified by:
flushin interfacejava.io.Flushable- Overrides:
flushin classjava.io.FilterOutputStream- Throws:
java.io.IOException- See Also:
OutputStream.flush()
-
-