Unless otherwise noted, passing a null argument to a constructor
or method in this class will cause a NullPointerException to be
thrown.
DeflaterOutputStream created without
specifying a compressor will create a compressor
at construction time, and close the compressor when the output stream
is closed.
If a compressor is specified when creating a DeflaterOutputStream, it is the
responsibility of the caller to close the
compressor 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.
Deflater
| Modifier and Type | Field and Description |
|---|---|
| protected byte[] | buf
Output buffer for writing compressed data. |
| private boolean | closed
Indicates that the stream has been closed.
|
| protected Deflater | def
Compressor for this stream. |
| pack-priv static final int | |
| private static final int | |
| private final boolean | |
| pack-priv boolean |
| Access | Constructor and Description |
|---|---|
| public | DeflaterOutputStream(OutputStream
the output stream out, Deflater the compressor ("deflater") def, int the output buffer size size, boolean if syncFlush)true the flush() method of this
instance flushes the compressor with flush mode
Deflater#SYNC_FLUSH before flushing the output
stream, otherwise only flushes the output streamCreates a new output stream with the specified compressor, buffer size and flush mode. |
| public | DeflaterOutputStream(OutputStream
the output stream out, Deflater the compressor ("deflater") def, int the output buffer size size)Creates a new output stream with the specified compressor and buffer size. |
| public | DeflaterOutputStream(OutputStream
the output stream out, Deflater the compressor ("deflater") def, boolean if syncFlush)true the flush() method of this
instance flushes the compressor with flush mode
Deflater#SYNC_FLUSH before flushing the output
stream, otherwise only flushes the output streamCreates a new output stream with the specified compressor, flush mode and a default buffer size. |
| public | DeflaterOutputStream(OutputStream
the output stream out, Deflater the compressor ("deflater") def)Creates a new output stream with the specified compressor and a default buffer size. |
| public | DeflaterOutputStream(OutputStream
the output stream out, boolean if syncFlush)true the flush() method of this
instance flushes the compressor with flush mode
Deflater#SYNC_FLUSH before flushing the output
stream, otherwise only flushes the output streamCreates a new output stream and compressor with the default compression level, a default buffer size and the specified flush mode. |
| public | DeflaterOutputStream(OutputStream
the output stream out)Creates a new output stream and compressor with the default compression level and a default buffer size. |
| Modifier and Type | Method and Description |
|---|---|
| public void | close()
Overrides java. Implements java. Writes remaining compressed data to the output stream and closes the underlying stream. |
| protected void | |
| public void | finish()
Finishes writing compressed data to the output stream without closing the underlying stream. |
| public void | flush()
Overrides java. Implements java. Flushes the compressed output stream. |
| public void | write(int
the byte to be written b)Overrides java. Writes a byte to the compressed output stream. |
| public void | write(byte[]
the data to be written b, int the start offset of the data off, int the length of the data len)Overrides java. Writes an array of bytes to the compressed output stream. |
| buf | back to summary |
|---|---|
| protected byte[] buf Output buffer for writing compressed data. | |
| closed | back to summary |
|---|---|
| private boolean closed Hides java. Indicates that the stream has been closed. | |
| def | back to summary |
|---|---|
| protected Deflater def Compressor for this stream. | |
| DEFAULT_BUF_SIZE | back to summary |
|---|---|
| pack-priv static final int DEFAULT_BUF_SIZE | |
| SYNC_FLUSH_MIN_BUF_SIZE | back to summary |
|---|---|
| private static final int SYNC_FLUSH_MIN_BUF_SIZE | |
| syncFlush | back to summary |
|---|---|
| private final boolean syncFlush | |
| usesDefaultDeflater | back to summary |
|---|---|
| pack-priv boolean usesDefaultDeflater | |
| DeflaterOutputStream | back to summary |
|---|---|
| public DeflaterOutputStream(OutputStream out, Deflater def, int size, boolean syncFlush) Creates a new output stream with the specified compressor, buffer size and flush mode. Closing this output stream will not close the given compressor.
| |
| DeflaterOutputStream | back to summary |
|---|---|
| public DeflaterOutputStream(OutputStream out, Deflater def, int size) Creates a new output stream with the specified compressor and buffer size. The new output stream instance is created as if by invoking
the 4-argument constructor Closing this output stream will not close the given compressor.
| |
| DeflaterOutputStream | back to summary |
|---|---|
| public DeflaterOutputStream(OutputStream out, Deflater def, boolean syncFlush) Creates a new output stream with the specified compressor, flush mode and a default buffer size. Closing this output stream will not close the given compressor.
| |
| DeflaterOutputStream | back to summary |
|---|---|
| public DeflaterOutputStream(OutputStream out, Deflater def) Creates a new output stream with the specified compressor and a default buffer size. The new output stream instance is created as if by invoking
the 3-argument constructor Closing this output stream will not close the given compressor.
| |
| DeflaterOutputStream | back to summary |
|---|---|
| public DeflaterOutputStream(OutputStream out, boolean syncFlush) Creates a new output stream and compressor with the default compression level, a default buffer size and the specified flush mode. The compressor will be closed when this output stream is closed.
| |
| DeflaterOutputStream | back to summary |
|---|---|
| public DeflaterOutputStream(OutputStream out) Creates a new output stream and compressor with the default compression level and a default buffer size. The new output stream instance is created as if by invoking
the 2-argument constructor The compressor will be closed when this output stream is closed.
| |
| close | back to summary |
|---|---|
| public void close() throws IOException Overrides java. Implements java. Writes remaining compressed data to the output stream and closes the underlying stream.
| |
| deflate | back to summary |
|---|---|
| protected void deflate() throws IOException Writes next block of compressed data to the output stream.
| |
| finish | back to summary |
|---|---|
| public void finish() throws IOException Finishes writing compressed data to the output stream without closing the underlying stream. Use this method when applying multiple filters in succession to the same output stream.
| |
| flush | back to summary |
|---|---|
| public void flush() throws IOException Overrides java. Implements java. Flushes the compressed output stream.
If
| |
| write | back to summary |
|---|---|
| public void write(int b) throws IOException Overrides java. Writes a byte to the compressed output stream. This method will block until the byte can be written.
| |
| write | back to summary |
|---|---|
| public void write(byte[] b, int off, int len) throws IOException Overrides java. Writes an array of bytes to the compressed output stream. This method will block until all the bytes are written.
| |