- 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.FilterOutputStream
A subclass ofOutputStream
that will compress data as it writes to another OutputStream. Not thread safe.- Since:
- 2.4.4
- See Also:
ZCompressor
-
-
Constructor Summary
Constructors Constructor 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 Description void
close()
This method also flushes data, including any partially compressed last byte.void
flush()
This flushes the buffer of all compressed data, excluding a possible partial last byte.long
getTotalCompressedBytes()
Answer the total number of compressed bytes written so far.long
getTotalSourceBytes()
Answer the total number of input (uncompressed) bytes written so far.void
releaseZCompressorOnClose(boolean value)
Sets a flag that will cause the ZCompressor resources to be released when this OutputStream is closed.void
write(byte[] b, int off, int len)
void
write(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:
write
in 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:
write
in classjava.io.FilterOutputStream
- Throws:
java.io.IOException
- See Also:
OutputStream.write(int)
-
close
public void close() throws java.io.IOException
This method also flushes data, including any partially compressed last byte.- Specified by:
close
in interfacejava.lang.AutoCloseable
- Specified by:
close
in interfacejava.io.Closeable
- Overrides:
close
in classjava.io.FilterOutputStream
- Throws:
java.io.IOException
- See Also:
OutputStream.close()
-
flush
public void flush() throws java.io.IOException
This 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:
flush
in interfacejava.io.Flushable
- Overrides:
flush
in classjava.io.FilterOutputStream
- Throws:
java.io.IOException
- See Also:
OutputStream.flush()
-
-