Package org.apache.commons.compress.compressors.zstandard

# Class ZstdCompressorOutputStream

java.lang.Object
java.io.OutputStream
java.io.FilterOutputStream
org.apache.commons.compress.CompressFilterOutputStream<com.github.luben.zstd.ZstdOutputStream>
org.apache.commons.compress.compressors.CompressorOutputStream<com.github.luben.zstd.ZstdOutputStream>
org.apache.commons.compress.compressors.zstandard.ZstdCompressorOutputStream

All Implemented Interfaces:
  `Closeable`, `Flushable`, `AutoCloseable`

public class ZstdCompressorOutputStream extends CompressorOutputStream<com.github.luben.zstd.ZstdOutputStream>
`CompressorOutputStream` implementation to create Zstandard encoded stream.

This class avoids making the underlying `zstd` classes part of the public or protected API. The underlying implementation is provided through the Zstandard JNI library which is based on zstd.

Since:
  1.16
See Also:
  - Zstandard JNI
  - zstd

- ## Nested Class Summary

  Nested Classes
  Modifier and Type
  Class
  Description
  `static final class`
  `ZstdCompressorOutputStream.Builder`
  Builds a new `ZstdCompressorOutputStream`.

- ## Field Summary

  ### Fields inherited from class java.io.FilterOutputStream

  `out`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `ZstdCompressorOutputStream(OutputStream outStream)`
  Constructs a new instance using default Zstd parameter values.
  `ZstdCompressorOutputStream(OutputStream outStream, int level)`
  Deprecated.
  Use `builder()`.
  `ZstdCompressorOutputStream(OutputStream outStream, int level, boolean closeFrameOnFlush)`
  Deprecated.
  Use `builder()`.
  `ZstdCompressorOutputStream(OutputStream outStream, int level, boolean closeFrameOnFlush, boolean checksum)`
  Deprecated.
  Use `builder()`.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `static ZstdCompressorOutputStream.Builder`
  `builder()`
  Constructs a new builder of `ZstdCompressorOutputStream`.
  `void`
  `write(byte[] buf, int off, int len)`

  ### Methods inherited from class org.apache.commons.compress.CompressFilterOutputStream

  `checkOpen, close, finish, isClosed, isFinished, out, write, write, writeUsAscii, writeUsAsciiRaw, writeUtf8`

  ### Methods inherited from class java.io.FilterOutputStream

  `flush, write, write`

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

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

- ## Constructor Details

  - ### ZstdCompressorOutputStream

    public ZstdCompressorOutputStream(OutputStream outStream) throws IOException
    Constructs a new instance using default Zstd parameter values.
    Parameters:
      `outStream` - the output stream.
    Throws:
      `IOException` - if an I/O error occurs.

  - ### ZstdCompressorOutputStream

    @Deprecated public ZstdCompressorOutputStream(OutputStream outStream, int level) throws IOException
    Deprecated.
    Use `builder()`.
    Constructs a new instance using default Zstd parameter values plus a compression level.
    Parameters:
      `outStream` - the output stream.
      `level` - The compression level, from 0 to 9, where the default is `ZstdConstants.ZSTD_CLEVEL_DEFAULT`.
    Throws:
      `IOException` - if an I/O error occurs.
    Since:
      1.18

  - ### ZstdCompressorOutputStream

    @Deprecated public ZstdCompressorOutputStream(OutputStream outStream, int level, boolean closeFrameOnFlush) throws IOException
    Deprecated.
    Use `builder()`.
    Constructs a new instance using default Zstd parameter values plus a compression level and checksum setting.
    Parameters:
      `outStream` - the output stream.
      `level` - The compression level, from 0 to 9, where the default is `ZstdConstants.ZSTD_CLEVEL_DEFAULT`.
      `closeFrameOnFlush` - whether to close the frame on flush.
    Throws:
      `IOException` - if an I/O error occurs.
    Since:
      1.18

  - ### ZstdCompressorOutputStream

    @Deprecated public ZstdCompressorOutputStream(OutputStream outStream, int level, boolean closeFrameOnFlush, boolean checksum) throws IOException
    Deprecated.
    Use `builder()`.
    Constructs a new instance using default Zstd parameter values plus a compression level, closeFrameOnFlush and checksum settings.
    Parameters:
      `outStream` - the output stream.
      `level` - The compression level, from 0 to 9, where the default is `ZstdConstants.ZSTD_CLEVEL_DEFAULT`.
      `closeFrameOnFlush` - whether to close the frame on flush.
      `checksum` - Whether a 32-bits checksum of content is written at end of frame.
    Throws:
      `IOException` - if an I/O error occurs.
    Since:
      1.18

- ## Method Details

  - ### builder

    public static ZstdCompressorOutputStream.Builder builder()
    Constructs a new builder of `ZstdCompressorOutputStream`.
    Returns:
      a new builder of `ZstdCompressorOutputStream`.
    Since:
      1.28.0

  - ### write

    public void write(byte[] buf, int off, int len) throws IOException
    Overrides:
      `write` in class `FilterOutputStream`
    Throws:
      `IOException`