Home All Groups
lz4-java / net / jpountz / lz4 / LZ4BlockOutputStream.html /
net.jpountz.lz4

Class LZ4BlockOutputStream

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

    public class LZ4BlockOutputStream
    extends java.io.FilterOutputStream
    Streaming LZ4 (not compatible with the LZ4 Frame format). This class compresses data into fixed-size blocks of compressed data. This class uses its own format and is not compatible with the LZ4 Frame format. For interoperability with other LZ4 tools, use LZ4FrameOutputStream, which is compatible with the LZ4 Frame format. This class remains for backward compatibility.
    See Also:
    LZ4BlockInputStream, LZ4FrameOutputStream
    • Field Summary

      • Fields inherited from class java.io.FilterOutputStream

        out
    • Constructor Summary

      Constructors 
      Constructor and Description
      LZ4BlockOutputStream(java.io.OutputStream out)
      Creates a new instance which compresses into blocks of 64 KB.
      LZ4BlockOutputStream(java.io.OutputStream out, int blockSize)
      Creates a new instance which compresses with the standard LZ4 compression algorithm.
      LZ4BlockOutputStream(java.io.OutputStream out, int blockSize, LZ4Compressor compressor)
      Creates a new instance which checks stream integrity using StreamingXXHash32 and doesn't sync flush.
      LZ4BlockOutputStream(java.io.OutputStream out, int blockSize, LZ4Compressor compressor, java.util.zip.Checksum checksum, boolean syncFlush)
      Creates a new OutputStream with configurable block size.
    • Method Summary

      Methods 
      Modifier and TypeMethod and Description
      voidclose() 
      voidfinish()
      Same as close() except that it doesn't close the underlying stream.
      voidflush()
      Flushes this compressed OutputStream.
      java.lang.StringtoString() 
      voidwrite(byte[] b) 
      voidwrite(byte[] b, int off, int len) 
      voidwrite(int b) 
      • Methods inherited from class java.lang.Object

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

      • LZ4BlockOutputStream

        public LZ4BlockOutputStream(java.io.OutputStream out,
                            int blockSize,
                            LZ4Compressor compressor,
                            java.util.zip.Checksum checksum,
                            boolean syncFlush)
        Creates a new OutputStream with configurable block size. Large blocks require more memory at compression and decompression time but should improve the compression ratio.
        Parameters:
        out - the OutputStream to feed
        blockSize - the maximum number of bytes to try to compress at once, must be >= 64 and <= 32 M
        compressor - the LZ4Compressor instance to use to compress data
        checksum - the Checksum instance to use to check data for integrity.
        syncFlush - true if pending data should also be flushed on flush()
      • LZ4BlockOutputStream

        public LZ4BlockOutputStream(java.io.OutputStream out,
                            int blockSize)
        Creates a new instance which compresses with the standard LZ4 compression algorithm.
        Parameters:
        out - the OutputStream to feed
        blockSize - the maximum number of bytes to try to compress at once, must be >= 64 and <= 32 M
        See Also:
        LZ4BlockOutputStream(OutputStream, int, LZ4Compressor), LZ4Factory.fastCompressor()
      • LZ4BlockOutputStream

        public LZ4BlockOutputStream(java.io.OutputStream out)
        Creates a new instance which compresses into blocks of 64 KB.
        Parameters:
        out - the OutputStream to feed
        See Also:
        LZ4BlockOutputStream(OutputStream, int)
    • 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
      • write

        public void write(byte[] b)
                   throws java.io.IOException
        Overrides:
        write 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
      • flush

        public void flush()
                   throws java.io.IOException
        Flushes this compressed OutputStream. If the stream has been created with syncFlush=true, pending data will be compressed and appended to the underlying OutputStream before calling OutputStream.flush() on the underlying stream. Otherwise, this method just flushes the underlying stream, so pending data might not be available for reading until finish() or close() is called.
        Specified by:
        flush in interface  java.io.Flushable
        Overrides:
        flush in class  java.io.FilterOutputStream
        Throws:
        java.io.IOException
      • finish

        public void finish()
                    throws java.io.IOException
        Same as close() except that it doesn't close the underlying stream. This can be useful if you want to keep on using the underlying stream.
        Throws:
        java.io.IOException - if an I/O error occurs.
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class  java.lang.Object