APIdia Launch Partner
Top Description Fields Constructors Methods
java.util.zip

public Class InflaterOutputStream

extends FilterOutputStream
Class Inheritance
Imports
java.io.FilterOutputStream, .IOException, .OutputStream, java.util.Objects

Implements an output stream filter for decompressing data stored in the "deflate" compression format.

Decompressor Usage

An InflaterOutputStream created without specifying a decompressor will create a decompressor at construction time, and close the decompressor when the output stream is closed or when finish() is called.

If a decompressor is specified when creating a InflaterOutputStream, it is the responsibility of the caller to close the decompressor after closing the output stream.

API Note

The close method should be called to release resources used by this stream, either directly, or with the try-with-resources statement.

Since
1.6
See Also
InflaterInputStream, DeflaterInputStream, DeflaterOutputStream

Field Summary

Modifier and TypeField and Description
protected final byte[]
buf

Output buffer for writing decompressed data.

private boolean
closed

Hides java.io.FilterOutputStream.closed.

true iff close() has been called.
private boolean
protected final Inflater
inf

Decompressor for this stream.

private boolean
usesDefaultInflater

Default decompressor is used.

private final byte[]
wbuf

Temporary write buffer.

Inherited from java.io.FilterOutputStream:
out

Constructor Summary

AccessConstructor and Description
public
InflaterOutputStream(OutputStream
output stream to write the decompressed data to
out
)

Creates a new output stream and decompressor with a default buffer size.

public
InflaterOutputStream(OutputStream
output stream to write the decompressed data to
out
,
Inflater
decompressor ("inflater") for this stream
infl
)

Creates a new output stream with the specified decompressor and a default buffer size.

public
InflaterOutputStream(OutputStream
output stream to write the decompressed data to
out
,
Inflater
decompressor ("inflater") for this stream
infl
,
int
decompression buffer size
bufLen
)

Creates a new output stream with the specified decompressor and buffer size.

Method Summary

Modifier and TypeMethod and Description
public void
close()

Overrides java.io.FilterOutputStream.close.

Implements java.io.Closeable.close.

Writes any remaining decompressed data to the output stream and closes the underlying output stream.

private void
ensureOpen()

Checks to make sure that this stream has not been closed.

public void
finish()

Writes any pending buffered decompressed data to the underlying output stream, without closing the underlying stream.

public void
flush()

Overrides java.io.FilterOutputStream.flush.

Implements java.io.Flushable.flush.

Flushes this output stream, writing any pending buffered decompressed data to the underlying output stream.

public void
write(int
a single byte of compressed data to decompress and write to the output stream
b
)

Overrides java.io.FilterOutputStream.write.

Writes a byte to the decompressed output stream.

public void
write(byte[]
buffer containing compressed data to decompress and write to the output stream
b
,
int
starting offset of the compressed data within b
off
,
int
number of bytes to decompress from b
len
)

Overrides java.io.FilterOutputStream.write.

Writes an array of bytes to the decompressed output stream.

Inherited from java.io.FilterOutputStream:
write

Field Detail

bufback to summary
protected final byte[] buf

Output buffer for writing decompressed data.

closedback to summary
private boolean closed

Hides java.io.FilterOutputStream.closed.

true iff close() has been called.

defaultInflaterClosedback to summary
private boolean defaultInflaterClosed
infback to summary
protected final Inflater inf

Decompressor for this stream.

usesDefaultInflaterback to summary
private boolean usesDefaultInflater

Default decompressor is used.

wbufback to summary
private final byte[] wbuf

Temporary write buffer.

Constructor Detail

InflaterOutputStreamback to summary
public InflaterOutputStream(OutputStream out)

Creates a new output stream and decompressor with a default buffer size.

The decompressor will be closed when this output stream is closed.

Parameters
out:OutputStream

output stream to write the decompressed data to

Exceptions
NullPointerException:
if out is null
InflaterOutputStreamback to summary
public InflaterOutputStream(OutputStream out, Inflater infl)

Creates a new output stream with the specified decompressor and a default buffer size.

Closing this output stream will not close the given decompressor.

Parameters
out:OutputStream

output stream to write the decompressed data to

infl:Inflater

decompressor ("inflater") for this stream

Exceptions
NullPointerException:
if out or infl is null
InflaterOutputStreamback to summary
public InflaterOutputStream(OutputStream out, Inflater infl, int bufLen)

Creates a new output stream with the specified decompressor and buffer size.

Closing this output stream will not close the given decompressor.

Parameters
out:OutputStream

output stream to write the decompressed data to

infl:Inflater

decompressor ("inflater") for this stream

bufLen:int

decompression buffer size

Exceptions
IllegalArgumentException:
if bufLen <= 0
NullPointerException:
if out or infl is null

Method Detail

closeback to summary
public void close() throws IOException

Overrides java.io.FilterOutputStream.close.

Implements java.io.Closeable.close.

Writes any remaining decompressed data to the output stream and closes the underlying output stream.

Implementation Specification

If not already closed, this method calls finish() before closing the underlying output stream.

Annotations
@Override
Exceptions
IOException:
if an I/O error occurs
ensureOpenback to summary
private void ensureOpen() throws IOException

Checks to make sure that this stream has not been closed.

finishback to summary
public void finish() throws IOException

Writes any pending buffered decompressed data to the underlying output stream, without closing the underlying stream.

Implementation Specification

This method calls flush() to write any pending buffered decompressed data.

If this InflaterOutputStream was created without specifying a decompressor, then this method closes the decompressor that was created at construction time. The InflaterOutputStream cannot then be used for any further writes.

Exceptions
IOException:
if an I/O error occurs or this stream is already closed
flushback to summary
public void flush() throws IOException

Overrides java.io.FilterOutputStream.flush.

Implements java.io.Flushable.flush.

Flushes this output stream, writing any pending buffered decompressed data to the underlying output stream.

Annotations
@Override
Exceptions
IOException:
if an I/O error occurs or this stream is already closed
writeback to summary
public void write(int b) throws IOException

Overrides java.io.FilterOutputStream.write.

Writes a byte to the decompressed output stream.

Parameters
b:int

a single byte of compressed data to decompress and write to the output stream

Annotations
@Override
Exceptions
IOException:
if an I/O error occurs or this stream is already closed
ZipException:
if a compression (ZIP) format error occurs
writeback to summary
public void write(byte[] b, int off, int len) throws IOException

Overrides java.io.FilterOutputStream.write.

Writes an array of bytes to the decompressed output stream.

Parameters
b:byte[]

buffer containing compressed data to decompress and write to the output stream

off:int

starting offset of the compressed data within b

len:int

number of bytes to decompress from b

Annotations
@Override
Exceptions
IOException:
if an I/O error occurs or this stream is already closed
IndexOutOfBoundsException:
if off < 0, or if len < 0, or if len > b.length - off
NullPointerException:
if b is null
ZipException:
if a compression (ZIP) format error occurs