java.lang.Objectjava.io.InputStream
java.io.FilterInputStream
java.util.zip.InflaterInputStream
java.util.zip.GZIPInputStream
public class GZIPInputStream
此类为读取 GZIP 文件格式的压缩数据实现流过滤器。
InflaterInputStream
| 字段摘要 | |
|---|---|
protected CRC32 |
crc 未压缩数据的 CRC-32。 |
protected boolean |
eos 指示输入流的结尾。 |
static int |
GZIP_MAGIC GZIP 头幻数。 |
| 从类 java.util.zip.InflaterInputStream 继承的字段 |
|---|
buf, inf, len |
| 从类 java.io.FilterInputStream 继承的字段 |
|---|
in |
| 构造方法摘要 | |
|---|---|
GZIPInputStream(InputStream in) 使用默认缓冲区大小创建新的输入流。 |
|
GZIPInputStream(InputStream in, int size) 使用指定缓冲区大小创建新的输入流。 |
|
| 方法摘要 | |
|---|---|
void |
close() 关闭此输入流并释放与该流关联的所有系统资源。 |
int |
read(byte[] buf, int off, int len) 将未压缩数据读入字节数组。 |
| 从类 java.util.zip.InflaterInputStream 继承的方法 |
|---|
available, fill, mark, markSupported, read, reset, skip |
| 从类 java.io.FilterInputStream 继承的方法 |
|---|
read |
| 从类 java.lang.Object 继承的方法 |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| 字段详细信息 |
|---|
protected CRC32 crc
protected boolean eos
public static final int GZIP_MAGIC
| 构造方法详细信息 |
|---|
public GZIPInputStream(InputStream in, int size) throws IOException
in - 输入流
size - 输入缓冲区大小
IOException - 如果发生 I/O 错误
IllegalArgumentException - 如果大小为 <= 0
public GZIPInputStream(InputStream in) throws IOException
in - 输入流
IOException - 如果发生 I/O 错误
| 方法详细信息 |
|---|
public int read(byte[] buf,
int off,
int len)
throws IOException
len 不为零,则在可以解压缩某些输入之前,此方法将处于阻塞状态;否则,不读取字节并且返回
0。
InflaterInputStream 中的
read
buf - 要读入数据的缓冲区
off - 目标数组
b 中的初始偏移量
len - 读取字节的最大数
NullPointerException - 如果
buf 为
null。
IndexOutOfBoundsException - 如果
off 为负,或者
len 为负或
len 大于
buf.length - off
IOException - 如果发生 I/O 错误或压缩输入数据损坏
FilterInputStream.in
public void close()
throws IOException
Closeable 中的
close
InflaterInputStream 中的
close
IOException - 如果发生 I/O 错误
FilterInputStream.in