public class GZIPInputStream
extends InflaterInputStream
java.lang.Object | ||||
↳ | java.io.InputStream | |||
↳ | java.io.FilterInputStream | |||
↳ | java.util.zip.InflaterInputStream | |||
↳ | java.util.zip.GZIPInputStream |
该类实现了用于读取GZIP文件格式的压缩数据的流过滤器。
也可以看看:
Constants |
|
---|---|
int |
GZIP_MAGIC GZIP标题幻数。 |
Fields |
|
---|---|
protected CRC32 |
crc CRC-32用于未压缩的数据。 |
protected boolean |
eos 表示输入流的结束。 |
Inherited fields |
---|
From class java.util.zip.InflaterInputStream
|
From class java.io.FilterInputStream
|
Public constructors |
|
---|---|
GZIPInputStream(InputStream in, int size) 用指定的缓冲区大小创建一个新的输入流。 |
|
GZIPInputStream(InputStream in) 用默认缓冲区大小创建一个新的输入流。 |
Public methods |
|
---|---|
void |
close() 关闭此输入流并释放与该流关联的所有系统资源。 |
int |
read(byte[] buf, int off, int len) 将未压缩的数据读入一个字节数组。 |
Inherited methods |
|
---|---|
From class java.util.zip.InflaterInputStream
|
|
From class java.io.FilterInputStream
|
|
From class java.io.InputStream
|
|
From class java.lang.Object
|
|
From interface java.io.Closeable
|
|
From interface java.lang.AutoCloseable
|
GZIPInputStream (InputStream in, int size)
用指定的缓冲区大小创建一个新的输入流。
Parameters | |
---|---|
in |
InputStream : the input stream |
size |
int : the input buffer size |
Throws | |
---|---|
ZipException |
if a GZIP format error has occurred or the compression method used is unsupported |
IOException |
if an I/O error has occurred |
IllegalArgumentException |
if size is <= 0 |
GZIPInputStream (InputStream in)
用默认缓冲区大小创建一个新的输入流。
Parameters | |
---|---|
in |
InputStream : the input stream |
Throws | |
---|---|
ZipException |
if a GZIP format error has occurred or the compression method used is unsupported |
IOException |
if an I/O error has occurred |
void close ()
关闭此输入流并释放与该流关联的所有系统资源。
Throws | |
---|---|
IOException |
if an I/O error has occurred |
int read (byte[] buf, int off, int len)
将未压缩的数据读入一个字节数组。 如果len
不为零,该方法将阻塞,直到某些输入可以解压缩为止; 否则,不读取字节并返回0
。
Parameters | |
---|---|
buf |
byte : the buffer into which the data is read |
off |
int : the start offset in the destination array b |
len |
int : the maximum number of bytes read |
Returns | |
---|---|
int |
the actual number of bytes read, or -1 if the end of the compressed input stream is reached |
Throws | |
---|---|
NullPointerException |
If buf is null . |
IndexOutOfBoundsException |
If off is negative, len is negative, or len is greater than buf.length - off |
ZipException |
if the compressed input data is corrupt. |
IOException |
if an I/O error has occurred. |