Package java.util.zip
Class InflaterOutputStream
- java.lang.Object
-
- java.io.OutputStream
-
- java.io.FilterOutputStream
-
- java.util.zip.InflaterOutputStream
-
- All Implemented Interfaces:
Closeable,Flushable,AutoCloseable
public class InflaterOutputStream extends FilterOutputStream
AnOutputStreamfilter 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[]bufprotected Inflaterinf-
Fields inherited from class java.io.FilterOutputStream
out
-
-
Constructor Summary
Constructors Constructor Description InflaterOutputStream(OutputStream out)Constructs anInflaterOutputStreamwith a newInflaterand an implementation-defined default internal buffer size.InflaterOutputStream(OutputStream out, Inflater inf)Constructs anInflaterOutputStreamwith the givenInflaterand an implementation-defined default internal buffer size.InflaterOutputStream(OutputStream out, Inflater inf, int bufferSize)Constructs anInflaterOutputStreamwith the givenInflaterand given internal buffer size.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()Writes remaining data into the output stream and closes the underlying output stream.voidfinish()Finishes writing current uncompressed data into the InflaterOutputStream without closing it.voidflush()Ensures that all pending data is sent out to the target stream.voidwrite(byte[] bytes, int offset, int byteCount)Writes to the decompressing output stream.voidwrite(int b)Writes a byte to the decompressing output stream.-
Methods inherited from class java.io.OutputStream
write
-
-
-
-
Field Detail
-
inf
protected final Inflater inf
-
buf
protected final byte[] buf
-
-
Constructor Detail
-
InflaterOutputStream
public InflaterOutputStream(OutputStream out)
Constructs anInflaterOutputStreamwith a newInflaterand an implementation-defined default internal buffer size.outis a destination for uncompressed data, and compressed data will be written to this stream.- Parameters:
out- the destinationOutputStream
-
InflaterOutputStream
public InflaterOutputStream(OutputStream out, Inflater inf)
Constructs anInflaterOutputStreamwith the givenInflaterand an implementation-defined default internal buffer size.outis a destination for uncompressed data, and compressed data will be written to this stream.- Parameters:
out- the destinationOutputStreaminf- theInflaterto be used for decompression
-
InflaterOutputStream
public InflaterOutputStream(OutputStream out, Inflater inf, int bufferSize)
Constructs anInflaterOutputStreamwith the givenInflaterand given internal buffer size.outis a destination for uncompressed data, and compressed data will be written to this stream.- Parameters:
out- the destinationOutputStreaminf- theInflaterto be used for decompressionbufferSize- the length in bytes of the internal buffer
-
-
Method Detail
-
close
public void close() throws IOExceptionWrites remaining data into the output stream and closes the underlying output stream.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Overrides:
closein classFilterOutputStream- Throws:
IOException- if an error occurs attempting to close this stream.
-
flush
public void flush() throws IOExceptionDescription copied from class:FilterOutputStreamEnsures that all pending data is sent out to the target stream. This implementation flushes the target stream.- Specified by:
flushin interfaceFlushable- Overrides:
flushin classFilterOutputStream- Throws:
IOException- if an error occurs attempting to flush this stream.
-
finish
public void finish() throws IOExceptionFinishes 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, ZipExceptionWrites a byte to the decompressing output stream.bshould be a byte of compressed input. The corresponding uncompressed data will be written to the underlying stream.- Overrides:
writein classFilterOutputStream- Parameters:
b- the byte- Throws:
IOException- if an I/O error occurs, or the stream has been closedZipException- if a zip exception occurs.
-
write
public void write(byte[] bytes, int offset, int byteCount) throws IOException, ZipExceptionWrites to the decompressing output stream. Thebytesarray should contain compressed input. The corresponding uncompressed data will be written to the underlying stream.- Overrides:
writein classFilterOutputStream- Parameters:
bytes- the buffer to write.offset- the index of the first byte inbufferto write.byteCount- the number of bytes inbufferto write.- Throws:
IOException- if an I/O error occurs, or the stream has been closedZipException- if a zip exception occurs.NullPointerException- ifb == null.IndexOutOfBoundsException- ifoff < 0 || len < 0 || off + len > b.length
-
-