public class DeflaterInputStream
extends FilterInputStream
| java.lang.Object | |||
| ↳ | java.io.InputStream | ||
| ↳ | java.io.FilterInputStream | ||
| ↳ | java.util.zip.DeflaterInputStream | ||
实现一个输入流过滤器,用于压缩“deflate”压缩格式的数据。
Fields |
|
|---|---|
protected final byte[] |
buf 输入缓冲区用于读取压缩数据。 |
protected final Deflater |
def 压缩机为这个流。 |
Inherited fields |
|---|
java.io.FilterInputStream
|
Public constructors |
|
|---|---|
DeflaterInputStream(InputStream in) 用默认的压缩器和缓冲区大小创建一个新的输入流。 |
|
DeflaterInputStream(InputStream in, Deflater defl) 用指定的压缩器和默认缓冲区大小创建一个新的输入流。 |
|
DeflaterInputStream(InputStream in, Deflater defl, int bufLen) 用指定的压缩器和缓冲区大小创建一个新的输入流。 |
|
Public methods |
|
|---|---|
int |
available() EOF达到后返回0,否则返回1。 |
void |
close() 关闭此输入流及其基础输入流,丢弃任何待解压缩的数据。 |
void |
mark(int limit) 此操作不受支持 。 |
boolean |
markSupported() |
int |
read() 从输入流中读取单个字节的压缩数据。 |
int |
read(byte[] b, int off, int len) 将压缩数据读入一个字节数组。 |
void |
reset() 此操作不受支持 。 |
long |
skip(long n) 跳过并丢弃输入流中的数据。 |
Inherited methods |
|
|---|---|
java.io.FilterInputStream
|
|
java.io.InputStream
|
|
java.lang.Object
|
|
java.io.Closeable
|
|
java.lang.AutoCloseable
|
|
DeflaterInputStream (InputStream in)
用默认的压缩器和缓冲区大小创建一个新的输入流。
| Parameters | |
|---|---|
in |
InputStream: input stream to read the uncompressed data to |
| Throws | |
|---|---|
NullPointerException |
if in is null |
DeflaterInputStream (InputStream in, Deflater defl)
用指定的压缩器和默认缓冲区大小创建一个新的输入流。
| Parameters | |
|---|---|
in |
InputStream: input stream to read the uncompressed data to |
defl |
Deflater: compressor ("deflater") for this stream |
| Throws | |
|---|---|
NullPointerException |
if in or defl is null |
DeflaterInputStream (InputStream in, Deflater defl, int bufLen)
用指定的压缩器和缓冲区大小创建一个新的输入流。
| Parameters | |
|---|---|
in |
InputStream: input stream to read the uncompressed data to |
defl |
Deflater: compressor ("deflater") for this stream |
bufLen |
int: compression buffer size |
| Throws | |
|---|---|
IllegalArgumentException |
if bufLen is <= 0 |
NullPointerException |
if in or defl is null |
int available ()
EOF达到后返回0,否则返回1。
程序不应该依赖此方法来返回可以不受阻塞地读取的实际字节数
| Returns | |
|---|---|
int |
zero after the end of the underlying input stream has been reached, otherwise always returns 1 |
| Throws | |
|---|---|
IOException |
if an I/O error occurs or if this stream is already closed |
void close ()
关闭此输入流及其基础输入流,丢弃任何待解压缩的数据。
| Throws | |
|---|---|
IOException |
if an I/O error occurs |
void mark (int limit)
此操作不受支持 。
| Parameters | |
|---|---|
limit |
int: maximum bytes that can be read before invalidating the position marker |
boolean markSupported ()
始终返回 false因为此输入流不支持 mark()和 reset()方法。
| Returns | |
|---|---|
boolean |
false, always |
int read ()
从输入流中读取单个字节的压缩数据。 该方法将阻塞,直到可以读取和压缩一些输入。
| Returns | |
|---|---|
int |
a single byte of compressed data, or -1 if the end of the uncompressed input stream is reached |
| Throws | |
|---|---|
IOException |
if an I/O error occurs or if this stream is already closed |
int read (byte[] b,
int off,
int len)
将压缩数据读入一个字节数组。 该方法将阻塞,直到可以读取和压缩一些输入。
| Parameters | |
|---|---|
b |
byte: buffer into which the data is read |
off |
int: starting offset of the data within b |
len |
int: maximum number of compressed bytes to read into b |
| Returns | |
|---|---|
int |
the actual number of bytes read, or -1 if the end of the uncompressed input stream is reached |
| Throws | |
|---|---|
IndexOutOfBoundsException |
if len > b.length - off |
IOException |
if an I/O error occurs or if this input stream is already closed |
long skip (long n)
跳过并丢弃输入流中的数据。 该方法可能会阻塞,直到读取并跳过指定的字节数。 注意:虽然n以long给出,但可以跳过的最大字节数为Integer.MAX_VALUE 。
| Parameters | |
|---|---|
n |
long: number of bytes to be skipped |
| Returns | |
|---|---|
long |
the actual number of bytes skipped |
| Throws | |
|---|---|
IOException |
if an I/O error occurs or if this stream is already closed |