Class PigzOutputStream

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

    public class PigzOutputStream
    extends java.io.FilterOutputStream
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static int DEFAULT_BLOCK_SIZE  
      static int DICT_LENGTH  
      • Fields inherited from class java.io.FilterOutputStream

        out
    • Constructor Summary

      Constructors 
      Constructor Description
      PigzOutputStream​(int compressionLevel, java.util.concurrent.Executor executor, int concurrency, java.io.OutputStream out)
      Creates a new output stream with the specified compression level, concurrency and a default block size.
      PigzOutputStream​(int compressionLevel, java.util.concurrent.Executor executor, int concurrency, java.io.OutputStream out, int blockSize)
      Creates a new output stream with the specified compression level, concurrency and block size.
      PigzOutputStream​(int compressionLevel, java.util.concurrent.Executor executor, int concurrency, java.io.OutputStream out, int blockSize, java.util.function.Function<PigzOutputStream,​PigzOutputStream.Compressor> compressorSupplier)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void close()
      Closes this output stream and releases any system resources associated with the stream.
      void flush()
      Flushes this output stream and forces any buffered output bytes to be written out to the stream.
      long getBytesCompressed()
      Returns how many bytes has been written to this OutputStream.
      long getBytesWritten()
      Returns how many bytes has been written to the underlying OutputStream.
      void write​(byte[] b, int off, int len)
      Writes len bytes from the specified byte array starting at offset off to this output stream.
      void write​(int b)
      Writes the specified byte to this output stream.
      • Methods inherited from class java.io.FilterOutputStream

        write
      • Methods inherited from class java.io.OutputStream

        nullOutputStream
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • PigzOutputStream

        public PigzOutputStream​(int compressionLevel,
                                @Nonnull
                                java.util.concurrent.Executor executor,
                                int concurrency,
                                @Nonnull @WillCloseWhenClosed
                                java.io.OutputStream out)
                         throws java.io.IOException
        Creates a new output stream with the specified compression level, concurrency and a default block size.
        Parameters:
        compressionLevel - gzip compression level, 1..9
        executor - executor to run threads.
        concurrency - maximum number of worker threads.
        out - the output stream.
        Throws:
        java.io.IOException - if an I/O error has occurred.
      • PigzOutputStream

        public PigzOutputStream​(int compressionLevel,
                                @Nonnull
                                java.util.concurrent.Executor executor,
                                int concurrency,
                                @Nonnull @WillCloseWhenClosed
                                java.io.OutputStream out,
                                int blockSize)
                         throws java.io.IOException
        Creates a new output stream with the specified compression level, concurrency and block size.
        Parameters:
        compressionLevel - gzip compression level, 1..9
        executor - executor to run threads.
        concurrency - maximum number of worker threads.
        out - the output stream.
        blockSize - compressor block size
        Throws:
        java.io.IOException - if an I/O error has occurred.
      • PigzOutputStream

        public PigzOutputStream​(int compressionLevel,
                                @Nonnull
                                java.util.concurrent.Executor executor,
                                int concurrency,
                                @Nonnull @WillCloseWhenClosed
                                java.io.OutputStream out,
                                int blockSize,
                                @Nonnull
                                java.util.function.Function<PigzOutputStream,​PigzOutputStream.Compressor> compressorSupplier)
                         throws java.io.IOException
        Throws:
        java.io.IOException
    • Method Detail

      • write

        public void write​(int b)
                   throws java.io.IOException
        Writes the specified byte to this output stream.

        Implements the abstract write method of OutputStream.

        Overrides:
        write in class java.io.FilterOutputStream
        Parameters:
        b - the byte.
        Throws:
        java.io.IOException - if an I/O error occurs.
      • write

        public void write​(@Nonnull
                          byte[] b,
                          int off,
                          int len)
                   throws java.io.IOException
        Writes len bytes from the specified byte array starting at offset off to this output stream.
        Overrides:
        write in class java.io.FilterOutputStream
        Parameters:
        b - the data.
        off - the start offset in the data.
        len - the number of bytes to write.
        Throws:
        java.io.IOException - if an I/O error occurs.
        See Also:
        FilterOutputStream.write(int)
      • flush

        public void flush()
                   throws java.io.IOException
        Flushes this output stream and forces any buffered output bytes to be written out to the stream.

        The flush method of FilterOutputStream calls the flush method of its underlying output stream.

        Specified by:
        flush in interface java.io.Flushable
        Overrides:
        flush in class java.io.FilterOutputStream
        Throws:
        java.io.IOException - if an I/O error occurs.
        See Also:
        FilterOutputStream.out
      • close

        public void close()
                   throws java.io.IOException
        Closes this output stream and releases any system resources associated with the stream.
        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 - if an I/O error occurs.
        See Also:
        FilterOutputStream.flush(), FilterOutputStream.out
      • getBytesCompressed

        public long getBytesCompressed()
        Returns how many bytes has been written to this OutputStream.
        Returns:
        number of bytes
      • getBytesWritten

        public long getBytesWritten()
        Returns how many bytes has been written to the underlying OutputStream.
        Returns:
        number of bytes