Module ibm.jzos
Package com.ibm.jzos

Class ZCompressorOutputStream

  • All Implemented Interfaces:
    java.io.Closeable, java.io.Flushable, java.lang.AutoCloseable

    public class ZCompressorOutputStream
    extends java.io.FilterOutputStream
    A subclass of OutputStream that will compress data as it writes to another OutputStream. Not thread safe.
    Since:
    2.4.4
    See Also:
    ZCompressor
    • 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)  
      • Methods inherited from class java.io.FilterOutputStream

        write
      • Methods inherited from class java.io.OutputStream

        nullOutputStream
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • 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 data
        out - 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 data
        out - the target OutputStream for compressed data
        buflen - 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 to false.
      • 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 class java.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 class java.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 interface java.lang.AutoCloseable
        Specified by:
        close in interface java.io.Closeable
        Overrides:
        close in class java.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 interface java.io.Flushable
        Overrides:
        flush in class java.io.FilterOutputStream
        Throws:
        java.io.IOException
        See Also:
        OutputStream.flush()