Skip to content

Most visited

Recently visited

navigation
Added in API level 1

DeflaterOutputStream

public class DeflaterOutputStream
extends FilterOutputStream

java.lang.Object
   ↳ java.io.OutputStream
     ↳ java.io.FilterOutputStream
       ↳ java.util.zip.DeflaterOutputStream
Known Direct Subclasses
Known Indirect Subclasses


This class provides an implementation of FilterOutputStream that compresses data using the DEFLATE algorithm. Basically it wraps the Deflater class and takes care of the buffering.

See also:

Summary

Fields

protected byte[] buf

The buffer for the data to be written to.

protected Deflater def

The deflater used.

Inherited fields

From class java.io.FilterOutputStream

Public constructors

DeflaterOutputStream(OutputStream os)

Constructs a new instance with a default-constructed Deflater.

DeflaterOutputStream(OutputStream os, Deflater def)

Constructs a new instance with the given Deflater.

DeflaterOutputStream(OutputStream os, Deflater def, int bufferSize)

Constructs a new instance with the given Deflater and buffer size.

DeflaterOutputStream(OutputStream os, boolean syncFlush)

Constructs a new instance with the given flushing behavior (see flush()).

DeflaterOutputStream(OutputStream os, Deflater def, boolean syncFlush)

Constructs a new instance with the given Deflater and flushing behavior (see flush()).

DeflaterOutputStream(OutputStream os, Deflater def, int bufferSize, boolean syncFlush)

Constructs a new instance with the given Deflater, buffer size, and flushing behavior (see flush()).

Public methods

void close()

Writes any unwritten compressed data to the underlying stream, the closes all underlying streams.

void finish()

Writes any unwritten data to the underlying stream.

void flush()

Flushes the underlying stream.

void write(byte[] buffer, int offset, int byteCount)

Compresses byteCount bytes of data from buf starting at offset and writes it to the underlying stream.

void write(int i)

Writes one byte to the target stream.

Protected methods

void deflate()

Compress the data in the input buffer and write it to the underlying stream.

Inherited methods

From class java.io.FilterOutputStream
From class java.io.OutputStream
From class java.lang.Object
From interface java.io.Closeable
From interface java.io.Flushable
From interface java.lang.AutoCloseable

Fields

buf

Added in API level 1
byte[] buf

The buffer for the data to be written to.

def

Added in API level 1
Deflater def

The deflater used.

Public constructors

DeflaterOutputStream

Added in API level 1
DeflaterOutputStream (OutputStream os)

Constructs a new instance with a default-constructed Deflater.

Parameters
os OutputStream

DeflaterOutputStream

Added in API level 1
DeflaterOutputStream (OutputStream os, 
                Deflater def)

Constructs a new instance with the given Deflater.

Parameters
os OutputStream
def Deflater

DeflaterOutputStream

Added in API level 1
DeflaterOutputStream (OutputStream os, 
                Deflater def, 
                int bufferSize)

Constructs a new instance with the given Deflater and buffer size.

Parameters
os OutputStream
def Deflater
bufferSize int

DeflaterOutputStream

Added in API level 19
DeflaterOutputStream (OutputStream os, 
                boolean syncFlush)

Constructs a new instance with the given flushing behavior (see flush()).

Parameters
os OutputStream
syncFlush boolean

DeflaterOutputStream

Added in API level 19
DeflaterOutputStream (OutputStream os, 
                Deflater def, 
                boolean syncFlush)

Constructs a new instance with the given Deflater and flushing behavior (see flush()).

Parameters
os OutputStream
def Deflater
syncFlush boolean

DeflaterOutputStream

Added in API level 19
DeflaterOutputStream (OutputStream os, 
                Deflater def, 
                int bufferSize, 
                boolean syncFlush)

Constructs a new instance with the given Deflater, buffer size, and flushing behavior (see flush()).

Parameters
os OutputStream
def Deflater
bufferSize int
syncFlush boolean

Public methods

close

Added in API level 1
void close ()

Writes any unwritten compressed data to the underlying stream, the closes all underlying streams. This stream can no longer be used after close() has been called.

Throws
IOException If an error occurs while closing the data compression process.

finish

Added in API level 1
void finish ()

Writes any unwritten data to the underlying stream. Does not close the stream.

Throws
IOException If an error occurs.

flush

Added in API level 1
void flush ()

Flushes the underlying stream. This flushes only the bytes that can be compressed at the highest level.

For deflater output streams constructed with the syncFlush parameter set to true, this first flushes all outstanding data so that it may be immediately read by its recipient. Doing so may degrade compression but improve interactive behavior.

Throws
IOException

write

Added in API level 1
void write (byte[] buffer, 
                int offset, 
                int byteCount)

Compresses byteCount bytes of data from buf starting at offset and writes it to the underlying stream.

Parameters
buffer byte: the buffer to write.
offset int: the index of the first byte in buffer to write.
byteCount int: the number of bytes in buffer to write.
Throws
IOException If an error occurs during writing.

write

Added in API level 1
void write (int i)

Writes one byte to the target stream. Only the low order byte of the integer oneByte is written.

Parameters
i int: the byte to be written.
Throws
IOException

Protected methods

deflate

Added in API level 1
void deflate ()

Compress the data in the input buffer and write it to the underlying stream.

Throws
IOException If an error occurs during deflation.
This site uses cookies to store your preferences for site-specific language and display options.

Hooray!

This class requires API level or higher

This doc is hidden because your selected API level for the documentation is . You can change the documentation API level with the selector above the left navigation.

For more information about specifying the API level your app requires, read Supporting Different Platform Versions.