Package java.util.zip

Class InflaterOutputStream

All Implemented Interfaces:
Closeable, Flushable, AutoCloseable

public class InflaterOutputStream
extends FilterOutputStream
An OutputStream filter to decompress data. Callers write compressed data in the "deflate" format, and uncompressed data is written to the underlying stream.
Since:
1.6
  • Field Summary

    Fields
    Modifier and Type Field Description
    protected byte[] buf  
    protected Inflater inf  

    Fields inherited from class java.io.FilterOutputStream

    out
  • Constructor Summary

    Constructors
    Constructor Description
    InflaterOutputStream​(OutputStream out)
    Constructs an InflaterOutputStream with a new Inflater and an implementation-defined default internal buffer size.
    InflaterOutputStream​(OutputStream out, Inflater inf)
    Constructs an InflaterOutputStream with the given Inflater and an implementation-defined default internal buffer size.
    InflaterOutputStream​(OutputStream out, Inflater inf, int bufferSize)
    Constructs an InflaterOutputStream with the given Inflater and given internal buffer size.
  • Method Summary

    Modifier and Type Method Description
    void close()
    Writes remaining data into the output stream and closes the underlying output stream.
    void finish()
    Finishes writing current uncompressed data into the InflaterOutputStream without closing it.
    void flush()
    Ensures that all pending data is sent out to the target stream.
    void write​(byte[] bytes, int offset, int byteCount)
    Writes to the decompressing output stream.
    void write​(int b)
    Writes a byte to the decompressing output stream.

    Methods inherited from class java.io.OutputStream

    write

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • inf

      protected final Inflater inf
    • buf

      protected final byte[] buf
  • Constructor Details

    • InflaterOutputStream

      public InflaterOutputStream​(OutputStream out)
      Constructs an InflaterOutputStream with a new Inflater and an implementation-defined default internal buffer size. out is a destination for uncompressed data, and compressed data will be written to this stream.
      Parameters:
      out - the destination OutputStream
    • InflaterOutputStream

      public InflaterOutputStream​(OutputStream out, Inflater inf)
      Constructs an InflaterOutputStream with the given Inflater and an implementation-defined default internal buffer size. out is a destination for uncompressed data, and compressed data will be written to this stream.
      Parameters:
      out - the destination OutputStream
      inf - the Inflater to be used for decompression
    • InflaterOutputStream

      public InflaterOutputStream​(OutputStream out, Inflater inf, int bufferSize)
      Constructs an InflaterOutputStream with the given Inflater and given internal buffer size. out is a destination for uncompressed data, and compressed data will be written to this stream.
      Parameters:
      out - the destination OutputStream
      inf - the Inflater to be used for decompression
      bufferSize - the length in bytes of the internal buffer
  • Method Details

    • close

      public void close() throws IOException
      Writes remaining data into the output stream and closes the underlying output stream.
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
      Overrides:
      close in class FilterOutputStream
      Throws:
      IOException - if an error occurs attempting to close this stream.
    • flush

      public void flush() throws IOException
      Description copied from class: FilterOutputStream
      Ensures that all pending data is sent out to the target stream. This implementation flushes the target stream.
      Specified by:
      flush in interface Flushable
      Overrides:
      flush in class FilterOutputStream
      Throws:
      IOException - if an error occurs attempting to flush this stream.
    • finish

      public void finish() throws IOException
      Finishes writing current uncompressed data into the InflaterOutputStream without closing it.
      Throws:
      IOException - if an I/O error occurs, or the stream has been closed
    • write

      public void write​(int b) throws IOException, ZipException
      Writes a byte to the decompressing output stream. b should be a byte of compressed input. The corresponding uncompressed data will be written to the underlying stream.
      Overrides:
      write in class FilterOutputStream
      Parameters:
      b - the byte
      Throws:
      IOException - if an I/O error occurs, or the stream has been closed
      ZipException - if a zip exception occurs.
    • write

      public void write​(byte[] bytes, int offset, int byteCount) throws IOException, ZipException
      Writes to the decompressing output stream. The bytes array should contain compressed input. The corresponding uncompressed data will be written to the underlying stream.
      Overrides:
      write in class FilterOutputStream
      Parameters:
      bytes - the buffer to write.
      offset - the index of the first byte in buffer to write.
      byteCount - the number of bytes in buffer to write.
      Throws:
      IOException - if an I/O error occurs, or the stream has been closed
      ZipException - if a zip exception occurs.
      NullPointerException - if b == null.
      IndexOutOfBoundsException - if off < 0 || len < 0 || off + len > b.length