org.lz4 / lz4-java / 1.5.0 / docs / net / jpountz / lz4 / LZ4FrameOutputStream.html
net.jpountz.lz4

Class LZ4FrameOutputStream

  • java.lang.Object
    • java.io.OutputStream
      • java.io.FilterOutputStream
        • net.jpountz.lz4.LZ4FrameOutputStream
  • All Implemented Interfaces:
    java.io.Closeable, java.io.Flushable, java.lang.AutoCloseable

    public class LZ4FrameOutputStream
    extends java.io.FilterOutputStream
    Implementation of the v1.5.1 LZ4 Frame format. This class is NOT thread safe.

    Not Supported:

    • Dependent blocks
    • Legacy streams
    • Multiple frames (one LZ4FrameOutputStream is one frame)

    Originally based on kafka's KafkaLZ4BlockOutputStream.

    See Also:
    LZ4 Framing Format Spec 1.5.1
    • Constructor Detail

      • LZ4FrameOutputStream

        public LZ4FrameOutputStream(java.io.OutputStream out,
                            LZ4FrameOutputStream.BLOCKSIZE blockSize,
                            long knownSize,
                            LZ4FrameOutputStream.FLG.Bits... bits)
                             throws java.io.IOException
        Creates a new OutputStream that will compress data using using fastest instances of LZ4Compressor and XXHash32.
        Parameters:
        out - the output stream to compress
        blockSize - the BLOCKSIZE to use
        knownSize - the size of the uncompressed data. A value less than zero means unknown.
        bits - a set of features to use
        Throws:
        java.io.IOException - if an I/O error occurs
      • LZ4FrameOutputStream

        public LZ4FrameOutputStream(java.io.OutputStream out,
                            LZ4FrameOutputStream.BLOCKSIZE blockSize,
                            long knownSize,
                            LZ4Compressor compressor,
                            XXHash32 checksum,
                            LZ4FrameOutputStream.FLG.Bits... bits)
                             throws java.io.IOException
        Creates a new OutputStream that will compress data using the specified instances of LZ4Compressor and XXHash32.
        Parameters:
        out - the output stream to compress
        blockSize - the BLOCKSIZE to use
        knownSize - the size of the uncompressed data. A value less than zero means unknown.
        compressor - the LZ4Compressor instance to use to compress data
        checksum - the XXHash32 instance to use to check data for integrity
        bits - a set of features to use
        Throws:
        java.io.IOException - if an I/O error occurs
      • LZ4FrameOutputStream

        public LZ4FrameOutputStream(java.io.OutputStream out,
                            LZ4FrameOutputStream.BLOCKSIZE blockSize)
                             throws java.io.IOException
        Creates a new OutputStream that will compress data using the LZ4 algorithm. The block independence flag is set, and none of the other flags are set.
        Parameters:
        out - The stream to compress
        blockSize - the BLOCKSIZE to use
        Throws:
        java.io.IOException - if an I/O error occurs
        See Also:
        LZ4FrameOutputStream(OutputStream, BLOCKSIZE, FLG.Bits...)
      • LZ4FrameOutputStream

        public LZ4FrameOutputStream(java.io.OutputStream out)
                             throws java.io.IOException
        Creates a new OutputStream that will compress data using the LZ4 algorithm with 4-MB blocks.
        Parameters:
        out - the output stream to compress
        Throws:
        java.io.IOException - if an I/O error occurs
        See Also:
        LZ4FrameOutputStream(OutputStream, BLOCKSIZE)
    • Method Detail

      • write

        public void write(int b)
                   throws java.io.IOException
        Overrides:
        write in class  java.io.FilterOutputStream
        Throws:
        java.io.IOException
      • 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
      • flush

        public void flush()
                   throws java.io.IOException
        Specified by:
        flush in interface  java.io.Flushable
        Overrides:
        flush in class  java.io.FilterOutputStream
        Throws:
        java.io.IOException
      • close

        public void close()
                   throws java.io.IOException
        Specified by:
        close in interface  java.io.Closeable
        Specified by:
        close in interface  java.lang.AutoCloseable
        Overrides:
        close in class  java.io.FilterOutputStream
        Throws:
        java.io.IOException