Most visited

Recently visited

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


该类实现了一个输出流过滤器,用于压缩“deflate”压缩格式的数据。 它也被用作其他类型压缩过滤器的基础,例如GZIPOutputStream。

也可以看看:

Summary

Fields

protected byte[] buf

输出缓冲区用于写入压缩数据。

protected Deflater def

压缩机为这个流。

Inherited fields

From class java.io.FilterOutputStream

Public constructors

DeflaterOutputStream(OutputStream out, Deflater def, int size, boolean syncFlush)

用指定的压缩器,缓冲区大小和刷新模式创建一个新的输出流。

DeflaterOutputStream(OutputStream out, Deflater def, int size)

用指定的压缩器和缓冲区大小创建一个新的输出流。

DeflaterOutputStream(OutputStream out, Deflater def, boolean syncFlush)

用指定的压缩器,刷新模式和默认缓冲区大小创建新的输出流。

DeflaterOutputStream(OutputStream out, Deflater def)

用指定的压缩器和默认缓冲区大小创建一个新的输出流。

DeflaterOutputStream(OutputStream out, boolean syncFlush)

使用默认压缩器,默认缓冲区大小和指定的刷新模式创建新的输出流。

DeflaterOutputStream(OutputStream out)

用默认的压缩器和缓冲区大小创建一个新的输出流。

Public methods

void close()

将剩余的压缩数据写入输出流并关闭基础流。

void finish()

完成将压缩数据写入输出流而不关闭底层流。

void flush()

刷新压缩的输出流。

void write(byte[] b, int off, int len)

将一个字节数组写入压缩输出流。

void write(int b)

将一个字节写入压缩的输出流。

Protected methods

void deflate()

将下一个压缩数据块写入输出流。

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

输出缓冲区用于写入压缩数据。

def

Added in API level 1
Deflater def

压缩机为这个流。

Public constructors

DeflaterOutputStream

Added in API level 19
DeflaterOutputStream (OutputStream out, 
                Deflater def, 
                int size, 
                boolean syncFlush)

用指定的压缩器,缓冲区大小和刷新模式创建一个新的输出流。

Parameters
out OutputStream: the output stream
def Deflater: the compressor ("deflater")
size int: the output buffer size
syncFlush boolean: if true the flush() method of this instance flushes the compressor with flush mode SYNC_FLUSH before flushing the output stream, otherwise only flushes the output stream
Throws
IllegalArgumentException if size is <= 0

DeflaterOutputStream

Added in API level 1
DeflaterOutputStream (OutputStream out, 
                Deflater def, 
                int size)

用指定的压缩器和缓冲区大小创建一个新的输出流。

通过调用4参数构造函数DeflaterOutputStream(out,def,size,false)来创建新的输出流实例。

Parameters
out OutputStream: the output stream
def Deflater: the compressor ("deflater")
size int: the output buffer size
Throws
IllegalArgumentException if size is <= 0

DeflaterOutputStream

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

用指定的压缩器,刷新模式和默认缓冲区大小创建新的输出流。

Parameters
out OutputStream: the output stream
def Deflater: the compressor ("deflater")
syncFlush boolean: if true the flush() method of this instance flushes the compressor with flush mode SYNC_FLUSH before flushing the output stream, otherwise only flushes the output stream

DeflaterOutputStream

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

用指定的压缩器和默认缓冲区大小创建一个新的输出流。

通过调用3参数的构造函数DeflaterOutputStream(out,def,false)来创建新的输出流实例。

Parameters
out OutputStream: the output stream
def Deflater: the compressor ("deflater")

DeflaterOutputStream

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

使用默认压缩器,默认缓冲区大小和指定的刷新模式创建新的输出流。

Parameters
out OutputStream: the output stream
syncFlush boolean: if true the flush() method of this instance flushes the compressor with flush mode SYNC_FLUSH before flushing the output stream, otherwise only flushes the output stream

DeflaterOutputStream

Added in API level 1
DeflaterOutputStream (OutputStream out)

用默认的压缩器和缓冲区大小创建一个新的输出流。

通过调用双参数构造函数DeflaterOutputStream(out,false)来创建新的输出流实例。

Parameters
out OutputStream: the output stream

Public methods

close

Added in API level 1
void close ()

将剩余的压缩数据写入输出流并关闭基础流。

Throws
IOException if an I/O error has occurred

finish

Added in API level 1
void finish ()

完成将压缩数据写入输出流而不关闭底层流。 连续应用多个过滤器到相同的输出流时使用此方法。

Throws
IOException if an I/O error has occurred

flush

Added in API level 1
void flush ()

刷新压缩的输出流。 如果syncFlushtrue这个压缩输出流构造时,这个方法首先刷新底层compressor与刷新模式SYNC_FLUSH强制所有未决数据刷新输出流,然后刷新输出流。 否则,此方法仅刷新输出流而不刷新compressor

Throws
IOException if an I/O error has occurred

write

Added in API level 1
void write (byte[] b, 
                int off, 
                int len)

将一个字节数组写入压缩输出流。 该方法将阻塞,直到写入所有字节。

Parameters
b byte: the data to be written
off int: the start offset of the data
len int: the length of the data
Throws
IOException if an I/O error has occurred

write

Added in API level 1
void write (int b)

将一个字节写入压缩的输出流。 该方法将阻塞,直到可以写入字节。

Parameters
b int: the byte to be written
Throws
IOException if an I/O error has occurred

Protected methods

deflate

Added in API level 1
void deflate ()

将下一个压缩数据块写入输出流。

Throws
IOException if an I/O error has occurred

Hooray!