Most visited

Recently visited

Added in API level 1

ZipInputStream

public class ZipInputStream
extends InflaterInputStream

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


该类实现一个输入流过滤器,用于读取ZIP文件格式的文件。 包括对压缩和未压缩条目的支持。

Summary

Constants

int CENATT

int CENATX

int CENCOM

int CENCRC

int CENDSK

int CENEXT

int CENFLG

int CENHDR

int CENHOW

int CENLEN

int CENNAM

int CENOFF

long CENSIG

int CENSIZ

int CENTIM

int CENVEM

int CENVER

int ENDCOM

int ENDHDR

int ENDOFF

long ENDSIG

int ENDSIZ

int ENDSUB

int ENDTOT

int EXTCRC

int EXTHDR

int EXTLEN

long EXTSIG

int EXTSIZ

int LOCCRC

int LOCEXT

int LOCFLG

int LOCHDR

int LOCHOW

int LOCLEN

int LOCNAM

long LOCSIG

int LOCSIZ

int LOCTIM

int LOCVER

Inherited fields

From class java.util.zip.InflaterInputStream
From class java.io.FilterInputStream

Public constructors

ZipInputStream(InputStream in)

创建一个新的ZIP输入流。

ZipInputStream(InputStream in, Charset charset)

创建一个新的ZIP输入流。

Public methods

int available()

EOF达到当前输入数据后返回0,否则返回1。

void close()

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

void closeEntry()

关闭当前的ZIP条目并定位流以读取下一个条目。

ZipEntry getNextEntry()

读取下一个ZIP文件条目并将该流定位在条目数据的开头。

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

从当前的ZIP条目读入一个字节数组。

long skip(long n)

跳过当前ZIP条目中指定的字节数。

Protected methods

ZipEntry createZipEntry(String name)

为指定的条目名称创建一个新的 ZipEntry对象。

Inherited methods

From class java.util.zip.InflaterInputStream
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

Constants

CENATT

Added in API level 21
int CENATT

常量值:36(0x00000024)

CENATX

Added in API level 21
int CENATX

常量值:38(0x00000026)

CENCOM

Added in API level 21
int CENCOM

常量值:32(0x00000020)

CENCRC

Added in API level 21
int CENCRC

常量值:16(0x00000010)

CENDSK

Added in API level 21
int CENDSK

常量值:34(0x00000022)

CENEXT

Added in API level 21
int CENEXT

常量值:30(0x0000001e)

CENFLG

Added in API level 21
int CENFLG

常量值:8(0x00000008)

CENHDR

Added in API level 21
int CENHDR

常量值:46(0x0000002e)

CENHOW

Added in API level 21
int CENHOW

常量值:10(0x0000000a)

CENLEN

Added in API level 21
int CENLEN

常量值:24(0x00000018)

CENNAM

Added in API level 21
int CENNAM

常量值:28(0x0000001c)

CENOFF

Added in API level 21
int CENOFF

常量值:42(0x0000002a)

CENSIG

Added in API level 21
long CENSIG

常量值:33639248(0x0000000002014b50)

CENSIZ

Added in API level 21
int CENSIZ

常量值:20(0x00000014)

CENTIM

Added in API level 21
int CENTIM

常量值:12(0x0000000c)

CENVEM

Added in API level 21
int CENVEM

常量值:4(0x00000004)

CENVER

Added in API level 21
int CENVER

常数值:6(0x00000006)

ENDCOM

Added in API level 21
int ENDCOM

常量值:20(0x00000014)

ENDHDR

Added in API level 21
int ENDHDR

常量值:22(0x00000016)

ENDOFF

Added in API level 21
int ENDOFF

常量值:16(0x00000010)

ENDSIG

Added in API level 21
long ENDSIG

常量值:101010256(0x0000000006054b50)

ENDSIZ

Added in API level 21
int ENDSIZ

常量值:12(0x0000000c)

ENDSUB

Added in API level 21
int ENDSUB

常量值:8(0x00000008)

ENDTOT

Added in API level 21
int ENDTOT

常量值:10(0x0000000a)

EXTCRC

Added in API level 21
int EXTCRC

常量值:4(0x00000004)

EXTHDR

Added in API level 21
int EXTHDR

常量值:16(0x00000010)

EXTLEN

Added in API level 21
int EXTLEN

Constant Value: 12 (0x0000000c)

EXTSIG

Added in API level 21
long EXTSIG

常量值:134695760(0x0000000008074b50)

EXTSIZ

Added in API level 21
int EXTSIZ

常量值:8(0x00000008)

LOCCRC

Added in API level 21
int LOCCRC

常量值:14(0x0000000e)

LOCEXT

Added in API level 21
int LOCEXT

Constant Value: 28 (0x0000001c)

LOCFLG

Added in API level 21
int LOCFLG

常数值:6(0x00000006)

LOCHDR

Added in API level 21
int LOCHDR

常量值:30(0x0000001e)

LOCHOW

Added in API level 21
int LOCHOW

常量值:8(0x00000008)

LOCLEN

Added in API level 21
int LOCLEN

常量值:22(0x00000016)

LOCNAM

Added in API level 21
int LOCNAM

常量值:26(0x0000001a)

LOCSIG

Added in API level 21
long LOCSIG

常量值:67324752(0x0000000004034b50)

LOCSIZ

Added in API level 21
int LOCSIZ

常量值:18(0x00000012)

LOCTIM

Added in API level 21
int LOCTIM

常量值:10(0x0000000a)

LOCVER

Added in API level 21
int LOCVER

常量值:4(0x00000004)

Public constructors

ZipInputStream

Added in API level 1
ZipInputStream (InputStream in)

创建一个新的ZIP输入流。

UTF-8 charset用于解码条目名称。

Parameters
in InputStream: the actual input stream

ZipInputStream

Added in API level 24
ZipInputStream (InputStream in, 
                Charset charset)

创建一个新的ZIP输入流。

Parameters
in InputStream: the actual input stream
charset Charset: The charset to be used to decode the ZIP entry name (ignored if the language encoding bit of the ZIP entry's general purpose bit flag is set).

Public methods

available

Added in API level 1
int available ()

EOF达到当前输入数据后返回0,否则返回1。

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

Returns
int 1 before EOF and 0 after EOF has reached for current entry.
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

closeEntry

Added in API level 1
void closeEntry ()

关闭当前的ZIP条目并定位流以读取下一个条目。

Throws
ZipException if a ZIP file error has occurred
IOException if an I/O error has occurred

getNextEntry

Added in API level 1
ZipEntry getNextEntry ()

读取下一个ZIP文件条目并将该流定位在条目数据的开头。

Returns
ZipEntry the next ZIP file entry, or null if there are no more entries
Throws
ZipException if a ZIP file error has occurred
IOException if an I/O error has occurred

read

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

从当前的ZIP条目读入一个字节数组。 如果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 entry is reached
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 file error has occurred
IOException if an I/O error has occurred

skip

Added in API level 1
long skip (long n)

跳过当前ZIP条目中指定的字节数。

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

Protected methods

createZipEntry

Added in API level 1
ZipEntry createZipEntry (String name)

为指定的条目名称创建一个新的 ZipEntry对象。

Parameters
name String: the ZIP file entry name
Returns
ZipEntry the ZipEntry just created

Hooray!