org.apache.commons.compress.compressors.lz4

## Class FramedLZ4CompressorInputStream

- java.lang.Object
- - java.io.InputStream
  - - org.apache.commons.compress.compressors.CompressorInputStream
    - - org.apache.commons.compress.compressors.lz4.FramedLZ4CompressorInputStream

- All Implemented Interfaces:
    Closeable, AutoCloseable, InputStreamStatistics

      public class FramedLZ4CompressorInputStream
      extends CompressorInputStream
      implements InputStreamStatistics

  CompressorInputStream for the LZ4 frame format.

  Based on the "spec" in the version "1.5.1 (31/03/2015)"

  Since:
    1.14
  See Also:
    LZ4 Frame Format Description
  This class is not thread-safe

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `FramedLZ4CompressorInputStream(InputStream in)` Creates a new input stream that decompresses streams compressed using the LZ4 frame format and stops after decompressing the first frame.
    `FramedLZ4CompressorInputStream(InputStream in, boolean decompressConcatenated)` Creates a new input stream that decompresses streams compressed using the LZ4 frame format.

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `close()`
    `long` | `getCompressedCount()`
    `static boolean` | `matches(byte[] signature, int length)` Checks if the signature matches what is expected for a .lz4 file.
    `int` | `read()`
    `int` | `read(byte[] b, int off, int len)`

    - ### Methods inherited from class org.apache.commons.compress.compressors.CompressorInputStream

      `count, count, getBytesRead, getCount, getUncompressedCount, pushedBackBytes`

    - ### Methods inherited from class java.io.InputStream

      `available, mark, markSupported, read, reset, skip`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

    - ### Methods inherited from interface org.apache.commons.compress.utils.InputStreamStatistics

      `getUncompressedCount`

- - ### Constructor Detail

    - #### FramedLZ4CompressorInputStream

          public FramedLZ4CompressorInputStream(InputStream in)
                                         throws IOException

      Creates a new input stream that decompresses streams compressed using the LZ4 frame format and stops after decompressing the first frame.
      Parameters:
        `in` - the InputStream from which to read the compressed data
      Throws:
        `IOException` - if reading fails

    - #### FramedLZ4CompressorInputStream

          public FramedLZ4CompressorInputStream(InputStream in,
                                                boolean decompressConcatenated)
                                         throws IOException

      Creates a new input stream that decompresses streams compressed using the LZ4 frame format.
      Parameters:
        `in` - the InputStream from which to read the compressed data
        `decompressConcatenated` - if true, decompress until the end of the input; if false, stop after the first LZ4 frame and leave the input position to point to the next byte after the frame stream
      Throws:
        `IOException` - if reading fails

  - ### Method Detail

    - #### matches

          public static boolean matches(byte[] signature,
                                        int length)

      Checks if the signature matches what is expected for a .lz4 file.

      .lz4 files start with a four byte signature.

      Parameters:
        `signature` - the bytes to check
        `length` - the number of bytes to check
      Returns:
        true if this is a .sz stream, false otherwise

    - #### close

          public void close()
                     throws IOException

      Specified by:
        `close` in interface `Closeable`
      Specified by:
        `close` in interface `AutoCloseable`
      Overrides:
        `close` in class `InputStream`
      Throws:
        `IOException`

    - #### getCompressedCount

          public long getCompressedCount()

      Specified by:
        `getCompressedCount` in interface `InputStreamStatistics`
      Returns:
        the amount of raw or compressed bytes read by the stream
      Since:
        1.17

    - #### read

          public int read()
                   throws IOException

      Specified by:
        `read` in class `InputStream`
      Throws:
        `IOException`

    - #### read

          public int read(byte[] b,
                          int off,
                          int len)
                   throws IOException

      Overrides:
        `read` in class `InputStream`
      Throws:
        `IOException`

Copyright © 2002–2022 The Apache Software Foundation. All rights reserved.