java.util.zip Class GZIPInputStream
java.lang.Object
java.io.InputStream
java.io.FilterInputStream
java.util.zip.InflaterInputStream
java.util.zip.GZIPInputStream
public class GZIPInputStream
extends
InflaterInputStream
This class implements a stream filter for reading compressed data in the GZIP format. 实现读取以GZIP格式压缩数据的流过滤器的类。
See Also:
InflaterInputStream
Field Summary protected CRC32
crc
CRC-32 for uncompressed data. 用于解压数据的CRC-32。 protected boolean
eos
Indicates end of input stream. 表示输入流尾。 static int
GZIP_MAGIC
GZIP header magic number. GZIP头magic数。
Method Summary void
close ()
Closes the input stream. 关闭输入流。 int
read (byte[] buf, int off, int len)
Reads uncompressed data into an array of bytes. 将解压数据读入到字节数组。
Methods inherited from class java.lang. Object clone , equals , finalize , getClass , hashCode , notify , notifyAll , toString , wait , wait , wait
crc
protected CRC32 crc
CRC-32 for uncompressed data. 用于解压数据的CRC-32。
eos
protected boolean eos
Indicates end of input stream. 表示输入流尾。
GZIP_MAGIC
public static final int GZIP_MAGIC
GZIP header magic number. GZIP头magic数。
See Also:
Constant Field Values
GZIPInputStream
public GZIPInputStream ( InputStream in,
int size)
throws IOException
Creates a new input stream with the specified buffer size. 使用指定缓冲大小创建输入流。
Parameters:
in
- the input stream 输入流
size
- the input buffer size 输入缓冲大小
Throws:
IOException
- if an I/O error has occurred 如果发生I/O错误抛出
IllegalArgumentException
- if size is <= 0 如果大小<= 0抛出
GZIPInputStream
public GZIPInputStream ( InputStream in)
throws IOException
Creates a new input stream with a default buffer size. 使用默认缓冲大小创建输入流。
Parameters:
in
- the input stream 输入流
Throws:
IOException
- if an I/O error has occurred 如果发生I/O错误抛出
read
public int read (byte[] buf,
int off,
int len)
throws IOException
Reads uncompressed data into an array of bytes. Blocks until enough input is available for decompression. 将解压数据读入到字节数组。阻塞直到足够的输入用于解压。
Overrides:
read
in class InflaterInputStream
Parameters:
buf
- the buffer into which the data is read 数据读入的缓冲
off
- the start offset of the data 数据的起始缓冲
len
- the maximum number of bytes read 读入的最大字节数
Returns:
the actual number of bytes read, or -1 if the end of the compressed input stream is reached 读入的实际字节数,如果到达已压缩的输入流末端,返回-1
Throws:
IOException
- if an I/O error has occurred or the compressed input data is corrupt 如果发生I/O错误或者压缩的输入数据被破坏抛出
close
public void close ()
throws IOException
Closes the input stream. 关闭输入流。
Overrides:
close
in class InflaterInputStream
Throws:
IOException
- if an I/O error has occurred 如果发生I/O错误抛出
Submit a bug or feature
For further API reference and developer documentation, see
Java 2 SDK SE Developer Documentation
. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples.
Copyright 2003 Sun Microsystems, Inc. All rights reserved. Use is subject to license terms . Also see the documentation redistribution policy .