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 Detail

      • buf

        protected final byte[] buf
    • Constructor Detail

      • 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 Detail

      • 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