加载中...
The Wayback Machine - https://sup1a9wrlpyh5li9ro.vcoronado.top/web/20090310013522/http://developer.android.com:80/reference/java/util/zip/DeflaterOutputStream.html
public class

DeflaterOutputStream

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

Class Overview

The DeflaterOutputStream class implements a stream filter for the writing of compressed data to a stream. Compression is performed by an instance of Deflater.

Summary

Fields
protected byte[] buf
protected Deflater def
[Expand]
Inherited Fields
From class java.io.FilterOutputStream
Public Constructors
DeflaterOutputStream(OutputStream os, Deflater def)
Constructs a new DeflaterOutputStream instance using os as the underlying stream.
DeflaterOutputStream(OutputStream os)
Constructs a new DeflaterOutputStream instance using os as the underlying stream.
DeflaterOutputStream(OutputStream os, Deflater def, int bsize)
Constructs a new DeflaterOutputStream instance using os as the underlying stream.
Public Methods
void close()
Writes any unwritten compressed data to the underlying stream, the closes all underlying streams.
void finish()
Write any unwritten data to the underlying stream.
void write(int i)
Writes the specified byte oneByte to this FilterOutputStream.
void write(byte[] buffer, int off, int nbytes)
Compress nbytes of data from buf starting at off and write it to the underlying stream.
Protected Methods
void deflate()
Compress the data in the input buffer and write it to the underlying stream.
[Expand]
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

Fields

protected byte[] buf

protected Deflater def

Public Constructors

public DeflaterOutputStream (OutputStream os, Deflater def)

Constructs a new DeflaterOutputStream instance using os as the underlying stream. The provided Deflater instance will be used to compress data.

Parameters
os OutputStream to receive compressed data
def Deflater to perform compression

public DeflaterOutputStream (OutputStream os)

Constructs a new DeflaterOutputStream instance using os as the underlying stream.

Parameters
os OutputStream to receive compressed data

public DeflaterOutputStream (OutputStream os, Deflater def, int bsize)

Constructs a new DeflaterOutputStream instance using os as the underlying stream. The provided Deflater instance will be used to compress data. The internal buffer for storing compressed data will be of size bsize.

Parameters
os OutputStream to receive compressed data
def Deflater to perform compression
bsize size of internal compression buffer

Public Methods

public 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 during close.

public void finish ()

Write any unwritten data to the underlying stream. Do not close the stream. This allows subsequent Deflater's to write to the same stream. This Deflater cannot be used again.

Throws
IOException If an error occurs.

public void write (int i)

Writes the specified byte oneByte to this FilterOutputStream. Only the low order byte of oneByte is written. This implementation writes the byte to the target OutputStream.

Parameters
i the byte to be written
Throws
IOException

public void write (byte[] buffer, int off, int nbytes)

Compress nbytes of data from buf starting at off and write it to the underlying stream.

Parameters
buffer Buffer of data to compress
off offset in buffer to extract data from
nbytes Number of bytes of data to compress and write
Throws
IOException If an error occurs during writing.

Protected Methods

protected void deflate ()

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

Throws
IOException If an error occurs during deflation.