转载自http://www.apihome.cn/api/java/ZipInputStream.html
java.util.zip
类 ZipInputStream
java.lang.Object
java.io.InputStream
java.io.FilterInputStream
java.util.zip.InflaterInputStream
java.util.zip.ZipInputStream
所有已实现的接口: - Closeable
直接已知子类: - JarInputStream
public class ZipInputStreamextends InflaterInputStream
此类为读取 ZIP 文件格式的文件实现输入流过滤器。包括对已压缩和未压缩条目的支持。
| 字段摘要 |
|---|
static int | CENATT
|
static int | CENATX
|
static int | CENCOM
|
static int | CENCRC
|
static int | CENDSK
|
static int | CENEXT
|
static int | CENFLG
|
static int | CENHDR
|
static int | CENHOW
|
static int | CENLEN
|
static int | CENNAM
|
static int | CENOFF
|
static long | CENSIG
|
static int | CENSIZ
|
static int | CENTIM
|
static int | CENVEM
|
static int | CENVER
|
static int | ENDCOM
|
static int | ENDHDR
|
static int | ENDOFF
|
static long | ENDSIG
|
static int | ENDSIZ
|
static int | ENDSUB
|
static int | ENDTOT
|
static int | EXTCRC
|
static int | EXTHDR
|
static int | EXTLEN
|
static long | EXTSIG
|
static int | EXTSIZ
|
static int | LOCCRC
|
static int | LOCEXT
|
static int | LOCFLG
|
static int | LOCHDR
|
static int | LOCHOW
|
static int | LOCLEN
|
static int | LOCNAM
|
static long | LOCSIG
|
static int | LOCSIZ
|
static int | LOCTIM
|
static int | LOCVER
|
| 从类 java.util.zip.InflaterInputStream 继承的字段 |
|---|
buf, inf, len |
| 从类 java.io.FilterInputStream 继承的字段 |
|---|
in |
| 构造方法摘要 |
|---|
ZipInputStream(InputStream in)
创建新的 ZIP 输入流。 |
| 方法摘要 |
|---|
int | available()
在 EOF 到达当前条目数据后,返回 0;否则,始终返回 1。 |
void | close()
关闭此输入流并释放与此流关联的所有系统资源。 |
void | closeEntry()
关闭当前 ZIP 条目并定位流以读取下一个条目。 |
protected ZipEntry | createZipEntry(String name)
为指定条目名称创建一个新的 ZipEntry 对象。 |
ZipEntry | getNextEntry()
读取下一个 ZIP 文件条目并将流定位到该条目数据的开始处。 |
int | read(byte[] b, int off, int len)
从当前 ZIP 条目读入字节数组。 |
long | skip(long n)
跳过当前 ZIP 条目中指定的字节数。 |
| 从类 java.util.zip.InflaterInputStream 继承的方法 |
|---|
fill, mark, markSupported, read, reset |
| 从类 java.io.FilterInputStream 继承的方法 |
|---|
read |
| 从类 java.lang.Object 继承的方法 |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
LOCSIG
public static final long LOCSIG
另请参见:- 常量字段值
EXTSIG
public static final long EXTSIG
另请参见:- 常量字段值
CENSIG
public static final long CENSIG
另请参见:- 常量字段值
ENDSIG
public static final long ENDSIG
另请参见:- 常量字段值
LOCHDR
public static final int LOCHDR
另请参见:- 常量字段值
EXTHDR
public static final int EXTHDR
另请参见:- 常量字段值
CENHDR
public static final int CENHDR
另请参见:- 常量字段值
ENDHDR
public static final int ENDHDR
另请参见:- 常量字段值
LOCVER
public static final int LOCVER
另请参见:- 常量字段值
LOCFLG
public static final int LOCFLG
另请参见:- 常量字段值
LOCHOW
public static final int LOCHOW
另请参见:- 常量字段值
LOCTIM
public static final int LOCTIM
另请参见:- 常量字段值
LOCCRC
public static final int LOCCRC
另请参见:- 常量字段值
LOCSIZ
public static final int LOCSIZ
另请参见:- 常量字段值
LOCLEN
public static final int LOCLEN
另请参见:- 常量字段值
LOCNAM
public static final int LOCNAM
另请参见:- 常量字段值
LOCEXT
public static final int LOCEXT
另请参见:- 常量字段值
EXTCRC
public static final int EXTCRC
另请参见:- 常量字段值
EXTSIZ
public static final int EXTSIZ
另请参见:- 常量字段值
EXTLEN
public static final int EXTLEN
另请参见:- 常量字段值
CENVEM
public static final int CENVEM
另请参见:- 常量字段值
CENVER
public static final int CENVER
另请参见:- 常量字段值
CENFLG
public static final int CENFLG
另请参见:- 常量字段值
CENHOW
public static final int CENHOW
另请参见:- 常量字段值
CENTIM
public static final int CENTIM
另请参见:- 常量字段值
CENCRC
public static final int CENCRC
另请参见:- 常量字段值
CENSIZ
public static final int CENSIZ
另请参见:- 常量字段值
CENLEN
public static final int CENLEN
另请参见:- 常量字段值
CENNAM
public static final int CENNAM
另请参见:- 常量字段值
CENEXT
public static final int CENEXT
另请参见:- 常量字段值
CENCOM
public static final int CENCOM
另请参见:- 常量字段值
CENDSK
public static final int CENDSK
另请参见:- 常量字段值
CENATT
public static final int CENATT
另请参见:- 常量字段值
CENATX
public static final int CENATX
另请参见:- 常量字段值
CENOFF
public static final int CENOFF
另请参见:- 常量字段值
ENDSUB
public static final int ENDSUB
另请参见:- 常量字段值
ENDTOT
public static final int ENDTOT
另请参见:- 常量字段值
ENDSIZ
public static final int ENDSIZ
另请参见:- 常量字段值
ENDOFF
public static final int ENDOFF
另请参见:- 常量字段值
ENDCOM
public static final int ENDCOM
另请参见:- 常量字段值
ZipInputStream
public ZipInputStream(InputStream in)
- 创建新的 ZIP 输入流。
参数:in - 实际输入流
getNextEntry
public ZipEntry getNextEntry()
throws IOException
- 读取下一个 ZIP 文件条目并将流定位到该条目数据的开始处。
-
返回:- 下一个 ZIP 文件条目;如果不存在更多条目,则返回 null
抛出:ZipException - 如果发生 ZIP 文件错误IOException - 如果发生 I/O 错误
closeEntry
public void closeEntry()
throws IOException
- 关闭当前 ZIP 条目并定位流以读取下一个条目。
-
抛出:ZipException - 如果发生 ZIP 文件错误IOException - 如果发生 I/O 错误
available
public int available()
throws IOException
- 在 EOF 到达当前条目数据后,返回 0;否则,始终返回 1。
程序不应依靠此方法返回无阻塞读取的实际字节数。
-
覆盖:- 类
InflaterInputStream 中的 available
-
返回:- EOF 到达当前条目前,返回 1;EOF 到达当前条目后,返回 0。
抛出:IOException - 如果发生 I/O 错误。
read
public int read(byte[] b,
int off,
int len)
throws IOException
- 从当前 ZIP 条目读入字节数组。如果
len 不为零,则在某些输入可用之前,此方法将处于阻塞状态;否则,不读取字节并且返回
0。
-
覆盖:- 类
InflaterInputStream 中的 read
-
参数:b - 要读入数据的缓冲区off - 目标数组 b 中的初始偏移量len - 读入字节的最大数 返回:- 读入字节的实际数;如果到达条目结尾,则返回 -1
抛出:NullPointerException - 如果 b 为 null。IndexOutOfBoundsException - 如果 off 为负,或者 len 为负或
len 大于 b.length - offZipException - 如果发生 ZIP 文件错误IOException - 如果发生 I/O 错误 另请参见:- FilterInputStream.in
skip
public long skip(long n)
throws IOException
- 跳过当前 ZIP 条目中指定的字节数。
-
覆盖:- 类
InflaterInputStream 中的 skip
-
参数:n - 要跳过的字节数 返回:- 跳过的实际字节数
抛出:ZipException - 如果发生 ZIP 文件错误IOException - 如果发生 I/O 错误IllegalArgumentException - 如果 n < 0
close
public void close()
throws IOException
- 关闭此输入流并释放与此流关联的所有系统资源。
-
指定者:- 接口
Closeable 中的 close 覆盖:- 类
InflaterInputStream 中的 close
-
抛出:IOException - 如果发生 I/O 错误。 另请参见:- FilterInputStream.in
createZipEntry
protected ZipEntry createZipEntry(String name)
- 为指定条目名称创建一个新的
ZipEntry 对象。 -
参数:name - ZIP 文件条目名称 返回:- 刚刚创建的 ZipEntry