- java.lang.Object
-
- java.io.InputStream
-
- java.io.FilterInputStream
-
- java.util.zip.InflaterInputStream
-
- java.util.zip.GZIPInputStream
-
- All Implemented Interfaces:
-
Closeable,AutoCloseable
public class GZIPInputStream extends InflaterInputStream
该类实现了一个流过滤器,用于读取GZIP文件格式的压缩数据。- 从以下版本开始:
- 1.1
- 另请参见:
-
InflaterInputStream
-
-
Field Summary
Fields Modifier and Type Field 描述 protected CRC32crcCRC-32用于未压缩数据。protected booleaneos表示输入流结束。static intGZIP_MAGICGZIP标题魔数。-
Fields inherited from class java.io.FilterInputStream
in
-
Fields inherited from class java.util.zip.InflaterInputStream
buf, inf, len
-
-
构造方法摘要
构造方法 Constructor 描述 GZIPInputStream(InputStream in)创建一个默认缓冲区大小的新输入流。GZIPInputStream(InputStream in, int size)创建具有指定缓冲区大小的新输入流。
-
方法摘要
所有方法 接口方法 具体的方法 Modifier and Type 方法 描述 voidclose()关闭此输入流并释放与流相关联的任何系统资源。intread(byte[] buf, int off, int len)将未压缩的数据读入字节数组。-
Methods inherited from class java.io.FilterInputStream
read
-
Methods inherited from class java.util.zip.InflaterInputStream
available, fill, mark, markSupported, read, reset, skip
-
Methods inherited from class java.io.InputStream
readAllBytes, readNBytes, transferTo
-
-
-
-
字段详细信息
-
crc
protected CRC32 crc
CRC-32用于未压缩数据。
-
eos
protected boolean eos
表示输入流结束。
-
GZIP_MAGIC
public static final int GZIP_MAGIC
GZIP标题魔数。- 另请参见:
- Constant Field Values
-
-
构造方法详细信息
-
GZIPInputStream
public GZIPInputStream(InputStream in, int size) throws IOException
创建具有指定缓冲区大小的新输入流。- 参数
-
in- 输入流 -
size- 输入缓冲区大小 - 异常
-
ZipException- 如果发生GZIP格式错误或不支持使用压缩方法 -
IOException- 如果发生I / O错误 -
IllegalArgumentException- 如果是size <= 0
-
GZIPInputStream
public GZIPInputStream(InputStream in) throws IOException
创建一个默认缓冲区大小的新输入流。- 参数
-
in- 输入流 - 异常
-
ZipException- 如果发生GZIP格式错误或不支持使用压缩方法 -
IOException- 如果发生I / O错误
-
-
方法详细信息
-
read
public int read(byte[] buf, int off, int len) throws IOException将未压缩的数据读入字节数组。 如果len不为零,则该方法将阻塞,直到可以解压缩某些输入; 否则,不会读取字节,并返回0。- 重写:
-
read在InflaterInputStream - 参数
-
buf- 读取数据的缓冲区 -
off- 目标阵列b的起始偏移量 -
len- 读取的最大字节数 - 结果
- 读取的实际字节数,如果达到压缩输入流的结尾,则为-1
- 异常
-
NullPointerException- 如果buf是null。 -
IndexOutOfBoundsException- 如果off为负数,则len为负数,或len大于buf.length - off -
ZipException- 如果压缩输入数据已损坏。 -
IOException- 如果发生I / O错误。 - 另请参见:
-
FilterInputStream.in
-
close
public void close() throws IOException关闭此输入流并释放与流相关联的任何系统资源。- Specified by:
-
close在接口AutoCloseable - Specified by:
-
close在接口Closeable - 重写:
-
close在InflaterInputStream - 异常
-
IOException- 如果发生I / O错误 - 另请参见:
-
FilterInputStream.in
-
-