org.apache.commons.compress.compressors.snappy

## Class SnappyCompressorInputStream

- java.lang.Object
- - java.io.InputStream
  - - org.apache.commons.compress.compressors.CompressorInputStream
    - - org.apache.commons.compress.compressors.snappy.SnappyCompressorInputStream

- All Implemented Interfaces:
    Closeable, AutoCloseable

      public class SnappyCompressorInputStream
      extends CompressorInputStream

  CompressorInputStream for the raw Snappy format.

  This implementation uses an internal buffer in order to handle the back-references that are at the heart of the LZ77 algorithm. The size of the buffer must be at least as big as the biggest offset used in the compressed stream. The current version of the Snappy algorithm as defined by Google works on 32k blocks and doesn't contain offsets bigger than 32k which is the default block size used by this class.

  Since:
    1.7
  See Also:
    Snappy compressed format description

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static int` | `DEFAULT_BLOCK_SIZE` Default block size

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `SnappyCompressorInputStream(InputStream is)` Constructor using the default buffer size of 32k.
    `SnappyCompressorInputStream(InputStream is, int blockSize)` Constructor using a configurable buffer size.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `int` | `available()`
    `void` | `close()`
    `int` | `getSize()` Get the uncompressed size of the stream
    `int` | `read()`
    `int` | `read(byte[] b, int off, int len)`

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

      `count, count, getBytesRead, getCount, pushedBackBytes`

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

      `mark, markSupported, read, reset, skip`

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

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

- - ### Field Detail

    - #### DEFAULT_BLOCK_SIZE

          public static final int DEFAULT_BLOCK_SIZE

      Default block size
      See Also:
        Constant Field Values

  - ### Constructor Detail

    - #### SnappyCompressorInputStream

          public SnappyCompressorInputStream(InputStream is)
                                      throws IOException

      Constructor using the default buffer size of 32k.
      Parameters:
        `is` - An InputStream to read compressed data from
      Throws:
        `IOException` - if reading fails

    - #### SnappyCompressorInputStream

          public SnappyCompressorInputStream(InputStream is,
                                     int blockSize)
                                      throws IOException

      Constructor using a configurable buffer size.
      Parameters:
        `is` - An InputStream to read compressed data from
        `blockSize` - The block size used in compression
      Throws:
        `IOException` - if reading fails

  - ### Method Detail

    - #### read

          public int read()
                   throws IOException

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

    - #### 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`

    - #### available

          public int available()

      Overrides:
        `available` in class `InputStream`

    - #### read

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

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

    - #### getSize

          public int getSize()

      Get the uncompressed size of the stream
      Returns:
        the uncompressed size

Copyright © 2016 The Apache Software Foundation. All rights reserved.