Most visited

Recently visited

Added in API level 9

DeflaterInputStream

public class DeflaterInputStream
extends FilterInputStream

java.lang.Object
    java.io.InputStream
      java.io.FilterInputStream
        java.util.zip.DeflaterInputStream


实现一个输入流过滤器,用于压缩“deflate”压缩格式的数据。

也可以看看:

摘要(Summary)

Fields

protected final byte[] buf

输入缓冲区用于读取压缩数据。

protected final Deflater def

压缩机为这个流。

Inherited fields

From class java.io.FilterInputStream

Public constructors

DeflaterInputStream(InputStream in)

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

DeflaterInputStream(InputStream in, Deflater defl)

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

DeflaterInputStream(InputStream in, Deflater defl, int bufLen)

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

公共方法(Public methods)

int available()

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

void close()

关闭此输入流及其基础输入流,丢弃任何待解压缩的数据。

void mark(int limit)

此操作不受支持

boolean markSupported()

始终返回 false因为此输入流不支持 mark()reset()方法。

int read()

从输入流中读取单个字节的压缩数据。

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

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

void reset()

此操作不受支持

long skip(long n)

跳过并丢弃输入流中的数据。

继承方法(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 9
byte[] buf

输入缓冲区用于读取压缩数据。

def

Added in API level 9
Deflater def

压缩机为这个流。

Public constructors

DeflaterInputStream

Added in API level 9
DeflaterInputStream (InputStream in)

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

参数(Parameters)
in InputStream: input stream to read the uncompressed data to
抛出异常(Throws)
NullPointerException if in is null

DeflaterInputStream

Added in API level 9
DeflaterInputStream (InputStream in, 
                Deflater defl)

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

参数(Parameters)
in InputStream: input stream to read the uncompressed data to
defl Deflater: compressor ("deflater") for this stream
抛出异常(Throws)
NullPointerException if in or defl is null

DeflaterInputStream

Added in API level 9
DeflaterInputStream (InputStream in, 
                Deflater defl, 
                int bufLen)

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

参数(Parameters)
in InputStream: input stream to read the uncompressed data to
defl Deflater: compressor ("deflater") for this stream
bufLen int: compression buffer size
抛出异常(Throws)
IllegalArgumentException if bufLen is <= 0
NullPointerException if in or defl is null

公共方法(Public methods)

available

Added in API level 9
int available ()

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

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

返回(Returns)
int zero after the end of the underlying input stream has been reached, otherwise always returns 1
抛出异常(Throws)
IOException if an I/O error occurs or if this stream is already closed

close

Added in API level 9
void close ()

关闭此输入流及其基础输入流,丢弃任何待解压缩的数据。

抛出异常(Throws)
IOException if an I/O error occurs

mark

Added in API level 9
void mark (int limit)

此操作不受支持

参数(Parameters)
limit int: maximum bytes that can be read before invalidating the position marker

markSupported

Added in API level 9
boolean markSupported ()

始终返回 false因为此输入流不支持 mark()reset()方法。

返回(Returns)
boolean false, always

read

Added in API level 9
int read ()

从输入流中读取单个字节的压缩数据。 该方法将阻塞,直到可以读取和压缩一些输入。

返回(Returns)
int a single byte of compressed data, or -1 if the end of the uncompressed input stream is reached
抛出异常(Throws)
IOException if an I/O error occurs or if this stream is already closed

read

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

将压缩数据读入一个字节数组。 该方法将阻塞,直到可以读取和压缩一些输入。

参数(Parameters)
b byte: buffer into which the data is read
off int: starting offset of the data within b
len int: maximum number of compressed bytes to read into b
返回(Returns)
int the actual number of bytes read, or -1 if the end of the uncompressed input stream is reached
抛出异常(Throws)
IndexOutOfBoundsException if len > b.length - off
IOException if an I/O error occurs or if this input stream is already closed

reset

Added in API level 9
void reset ()

此操作不受支持

抛出异常(Throws)
IOException always thrown

skip

Added in API level 9
long skip (long n)

跳过并丢弃输入流中的数据。 该方法可能会阻塞,直到读取并跳过指定的字节数。 注意:虽然nlong给出,但可以跳过的最大字节数为Integer.MAX_VALUE

参数(Parameters)
n long: number of bytes to be skipped
返回(Returns)
long the actual number of bytes skipped
抛出异常(Throws)
IOException if an I/O error occurs or if this stream is already closed

Hooray!