public class GZIPOutputStream
extends DeflaterOutputStream
| java.lang.Object | ||||
| ↳ | java.io.OutputStream | |||
| ↳ | java.io.FilterOutputStream | |||
| ↳ | java.util.zip.DeflaterOutputStream | |||
| ↳ | java.util.zip.GZIPOutputStream | |||
该类实现了用于以GZIP文件格式写入压缩数据的流过滤器。
Fields |
|
|---|---|
protected CRC32 |
crc 未压缩数据的CRC-32。 |
Inherited fields |
|---|
java.util.zip.DeflaterOutputStream
|
java.io.FilterOutputStream
|
Public constructors |
|
|---|---|
GZIPOutputStream(OutputStream out, int size) 用指定的缓冲区大小创建一个新的输出流。 |
|
GZIPOutputStream(OutputStream out, int size, boolean syncFlush) 用指定的缓冲区大小和刷新模式创建新的输出流。 |
|
GZIPOutputStream(OutputStream out) 用默认缓冲区大小创建一个新的输出流。 |
|
GZIPOutputStream(OutputStream out, boolean syncFlush) 使用默认缓冲区大小和指定的刷新模式创建新的输出流。 |
|
Public methods |
|
|---|---|
void |
finish() 完成将压缩数据写入输出流而不关闭底层流。 |
void |
write(byte[] buf, int off, int len) 将字节数组写入压缩输出流。 |
Inherited methods |
|
|---|---|
java.util.zip.DeflaterOutputStream
|
|
java.io.FilterOutputStream
|
|
java.io.OutputStream
|
|
java.lang.Object
|
|
java.io.Closeable
|
|
java.io.Flushable
|
|
java.lang.AutoCloseable
|
|
GZIPOutputStream (OutputStream out, int size)
用指定的缓冲区大小创建一个新的输出流。
通过调用3参数构造函数GZIPOutputStream(out,size,false)来创建新的输出流实例。
| Parameters | |
|---|---|
out |
OutputStream: the output stream |
size |
int: the output buffer size |
| Throws | |
|---|---|
IOException |
If an I/O error has occurred. |
IllegalArgumentException |
if size is <= 0 |
GZIPOutputStream (OutputStream out, int size, boolean syncFlush)
用指定的缓冲区大小和刷新模式创建新的输出流。
| Parameters | |
|---|---|
out |
OutputStream: the output stream |
size |
int: the output buffer size |
syncFlush |
boolean: if true invocation of the inherited 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 | |
|---|---|
IOException |
If an I/O error has occurred. |
IllegalArgumentException |
if size is <= 0 |
GZIPOutputStream (OutputStream out)
用默认缓冲区大小创建一个新的输出流。
通过调用2参数的构造函数GZIPOutputStream(out,false)来创建新的输出流实例。
| Parameters | |
|---|---|
out |
OutputStream: the output stream |
| Throws | |
|---|---|
IOException |
If an I/O error has occurred. |
GZIPOutputStream (OutputStream out, boolean syncFlush)
使用默认缓冲区大小和指定的刷新模式创建新的输出流。
| Parameters | |
|---|---|
out |
OutputStream: the output stream |
syncFlush |
boolean: if true invocation of the inherited 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 | |
|---|---|
IOException |
If an I/O error has occurred. |
void finish ()
完成将压缩数据写入输出流而不关闭底层流。 连续应用多个过滤器到相同的输出流时使用此方法。
| Throws | |
|---|---|
IOException |
if an I/O error has occurred |
void write (byte[] buf,
int off,
int len)
将字节数组写入压缩输出流。 该方法将阻塞,直到写入所有字节。
| Parameters | |
|---|---|
buf |
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. |