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 |
|---|
java.util.zip.InflaterInputStream
|
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) |
|
|---|---|
java.util.zip.InflaterInputStream
|
|
java.io.FilterInputStream
|
|
java.io.InputStream
|
|
java.lang.Object
|
|
java.io.Closeable
|
|
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. |