Most visited

Recently visited

Added in API level 1

InflaterInputStream

public class InflaterInputStream
extends FilterInputStream

java.lang.Object
   ↳ java.io.InputStream
     ↳ java.io.FilterInputStream
       ↳ java.util.zip.InflaterInputStream
Known Direct Subclasses
Known Indirect Subclasses


这个类实现了一个流过滤器,用于以“deflate”压缩格式解压缩数据。 它也被用作其他解压过滤器的基础,比如GZIPInputStream。

也可以看看:

Summary

Fields

protected byte[] buf

输入缓冲区用于解压缩。

protected boolean closed

protected Inflater inf

这个流的解压缩器。

protected int len

输入缓冲区的长度。

Inherited fields

From class java.io.FilterInputStream

Public constructors

InflaterInputStream(InputStream in, Inflater inf, int size)

用指定的解压缩器和缓冲区大小创建一个新的输入流。

InflaterInputStream(InputStream in, Inflater inf)

用指定的解压缩器和默认缓冲区大小创建一个新的输入流。

InflaterInputStream(InputStream in)

用默认的解压缩器和缓冲区大小创建一个新的输入流。

Public methods

int available()

EOF达到后返回0,否则返回1。

void close()

关闭此输入流并释放与该流关联的所有系统资源。

void mark(int readlimit)

标记此输入流中的当前位置。

boolean markSupported()

测试此输入流是否支持 markreset方法。

int read()

读取一个未压缩的数据字节。

int read(byte[] b, int off, int len)

将未压缩的数据读入一个字节数组。

void reset()

将此流重新定位到上次在此输入流上调用 mark方法时的位置。

long skip(long n)

跳过未压缩数据的指定字节数。

Protected methods

void fill()

用更多数据填充输入缓冲区以解压缩。

Inherited methods

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

Fields

buf

Added in API level 1
byte[] buf

输入缓冲区用于解压缩。

closed

Added in API level 24
boolean closed

inf

Added in API level 1
Inflater inf

这个流的解压缩器。

len

Added in API level 1
int len

输入缓冲区的长度。

Public constructors

InflaterInputStream

Added in API level 1
InflaterInputStream (InputStream in, 
                Inflater inf, 
                int size)

用指定的解压缩器和缓冲区大小创建一个新的输入流。

Parameters
in InputStream: the input stream
inf Inflater: the decompressor ("inflater")
size int: the input buffer size
Throws
IllegalArgumentException if size is <= 0

InflaterInputStream

Added in API level 1
InflaterInputStream (InputStream in, 
                Inflater inf)

用指定的解压缩器和默认缓冲区大小创建一个新的输入流。

Parameters
in InputStream: the input stream
inf Inflater: the decompressor ("inflater")

InflaterInputStream

Added in API level 1
InflaterInputStream (InputStream in)

用默认的解压缩器和缓冲区大小创建一个新的输入流。

Parameters
in InputStream: the input stream

Public methods

available

Added in API level 1
int available ()

EOF达到后返回0,否则返回1。

程序不应该依赖此方法来返回可以不受阻塞地读取的实际字节数。

Returns
int 1 before EOF and 0 after EOF.
Throws
IOException if an I/O error occurs.

close

Added in API level 1
void close ()

关闭此输入流并释放与该流关联的所有系统资源。

Throws
IOException if an I/O error has occurred

mark

Added in API level 1
void mark (int readlimit)

标记此输入流中的当前位置。

mark方法 InflaterInputStream什么都不做。

Parameters
readlimit int: the maximum limit of bytes that can be read before the mark position becomes invalid.

也可以看看:

markSupported

Added in API level 1
boolean markSupported ()

测试此输入流是否支持markreset方法。 markSupported方法InflaterInputStream回报false

Returns
boolean a boolean indicating if this stream type supports the mark and reset methods.

也可以看看:

read

Added in API level 1
int read ()

读取一个未压缩的数据字节。 此方法将阻塞,直到有足够的输入可用于解压缩。

Returns
int the byte read, or -1 if end of compressed input is reached
Throws
IOException if an I/O error has occurred

read

Added in API level 1
int read (byte[] b, 
                int off, 
                int len)

将未压缩的数据读入一个字节数组。 如果len不为零,该方法将阻塞,直到某些输入可以解压缩为止; 否则,不读取字节并返回0

Parameters
b 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 is reached or a preset dictionary is needed
Throws
NullPointerException If b is null.
IndexOutOfBoundsException If off is negative, len is negative, or len is greater than b.length - off
ZipException if a ZIP format error has occurred
IOException if an I/O error has occurred

reset

Added in API level 1
void reset ()

将此流重新定位到上次在此输入流上调用 mark方法时的位置。

InflaterInputStream的方法 reset除了抛出 IOException之外什么都不 IOException

Throws
IOException if this method is invoked.

也可以看看:

skip

Added in API level 1
long skip (long n)

跳过未压缩数据的指定字节数。

Parameters
n long: the number of bytes to skip
Returns
long the actual number of bytes skipped.
Throws
IOException if an I/O error has occurred
IllegalArgumentException if n < 0

Protected methods

fill

Added in API level 1
void fill ()

用更多数据填充输入缓冲区以解压缩。

Throws
IOException if an I/O error has occurred

Hooray!