public class DeflaterOutputStream
extends FilterOutputStream
| java.lang.Object | |||
| java.io.OutputStream | |||
| java.io.FilterOutputStream | |||
| java.util.zip.DeflaterOutputStream | |||
| |
| |
该类实现了一个输出流过滤器,用于压缩“deflate”压缩格式的数据。 它也被用作其他类型压缩过滤器的基础,例如GZIPOutputStream。
也可以看看:
Fields |
|
|---|---|
protected byte[] |
buf 输出缓冲区用于写入压缩数据。 |
protected Deflater |
def 压缩机为这个流。 |
Inherited fields |
|---|
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) |
|
|---|---|
java.io.FilterOutputStream
|
|
java.io.OutputStream
|
|
java.lang.Object
|
|
java.io.Closeable
|
|
java.io.Flushable
|
|
java.lang.AutoCloseable
|
|
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 (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 (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 (OutputStream out, Deflater def)
用指定的压缩器和默认缓冲区大小创建一个新的输出流。
通过调用3参数的构造函数DeflaterOutputStream(out,def,false)来创建新的输出流实例。
| 参数(Parameters) | |
|---|---|
out |
OutputStream: the output stream |
def |
Deflater: the compressor ("deflater") |
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 (OutputStream out)
用默认的压缩器和缓冲区大小创建一个新的输出流。
通过调用双参数构造函数DeflaterOutputStream(out,false)来创建新的输出流实例。
| 参数(Parameters) | |
|---|---|
out |
OutputStream: the output stream |
void close ()
将剩余的压缩数据写入输出流并关闭基础流。
| 抛出异常(Throws) | |
|---|---|
IOException |
if an I/O error has occurred |
void finish ()
完成将压缩数据写入输出流而不关闭底层流。 连续应用多个过滤器到相同的输出流时使用此方法。
| 抛出异常(Throws) | |
|---|---|
IOException |
if an I/O error has occurred |
void flush ()
刷新压缩的输出流。 如果syncFlush是true这个压缩输出流构造时,这个方法首先刷新底层compressor与刷新模式SYNC_FLUSH强制所有未决数据刷新输出流,然后刷新输出流。 否则,此方法仅刷新输出流而不刷新compressor 。
| 抛出异常(Throws) | |
|---|---|
IOException |
if an I/O error has occurred |
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 |
void write (int b)
将一个字节写入压缩的输出流。 该方法将阻塞,直到可以写入字节。
| 参数(Parameters) | |
|---|---|
b |
int: the byte to be written |
| 抛出异常(Throws) | |
|---|---|
IOException |
if an I/O error has occurred |
void deflate ()
将下一个压缩数据块写入输出流。
| 抛出异常(Throws) | |
|---|---|
IOException |
if an I/O error has occurred |