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
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 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
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 Details
-
inf
-
buf
protected final byte[] buf
-
-
Constructor Details
-
InflaterOutputStream
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
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
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 Details
-
close
Writes 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
Description 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
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
Writes 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
Writes 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
-