[/url] [url=file:///F:/资料/文字资料/j2sdk-1_4_2-doc/docs/api/overview-summary.html]Overview
Class
JavaTM 2 Platform
Std. Ed. v1.4.2
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
java.util.zip
Class ZipFilejava.lang.Object
java.util.zip.ZipFile
All Implemented Interfaces: java.util.zip.ZipConstants Direct Known Subclasses: JarFile public class ZipFile extends Object implements java.util.zip.ZipConstantsThis class is used to read entries from a zip file. 用于从zip文件中读取项的类。
Field Summary
static int
static int
static int
static int
static int
static int
static int
static int
static int
static int
static int
static int
static long
static int
static int
static int
static int
static int
static int
static int
static long
static int
static int
static int
static int
static int
static int
static long
static int
static int
static int
static int
static int
static int
static int
static int
static long
static int
static int
static int
static int
Mode flag to open a zip file and mark it for deletion. zip文件打开的模式标记,标记为删除。
static int
Mode flag to open a zip file for reading. zip文件打开的模式标记,标记为读取。
Constructor Summary
Opens a ZIP file for reading given the specified File object. 打开一个ZIP文件来读取指定的File对象。
Opens a new ZipFile to read from the specified File object in the specified mode. 打开一个ZipFile,按指定的模式读取指定的File对象。
Opens a zip file for reading. 打开一个要读取的zip文件。
Method Summary
void
close()
Closes the ZIP file. 关闭ZIP文件。
entries()
Returns an enumeration of the ZIP file entries. 返回ZIP文件项的枚举。
protected void
finalize()
Ensures that the close method of this ZIP file is called when there are no more references to it. 确保没有对ZIP文件的引用时,调用close方法。
Returns the zip file entry for the specified name, or null if not found. 返回给定名称的zip文件项,如果未找到,返回null。
getInputStream(ZipEntry entry)
Returns an input stream for reading the contents of the specified zip file entry. 返回读取指定zip文件项内容的输入流。
getName()
Returns the path name of the ZIP file. 返回ZIP文件的路径名。
int
size()
Returns the number of entries in the ZIP file. 返回ZIP文件中项的数目。
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Field Detail
OPEN_READpublic static final int OPEN_READ
Mode flag to open a zip file for reading. zip文件打开的模式标记,标记为读取。
See Also: Constant Field ValuesOPEN_DELETEpublic static final int OPEN_DELETE
Mode flag to open a zip file and mark it for deletion. The file will be deleted some time between the moment that it is opened and the moment that it is closed, but its contents will remain accessible via the ZipFile object until either the close method is invoked or the virtual machine exits. zip文件打开的模式标记,标记为删除。删除文件一般在打开时刻和关闭时刻之间,但其内容仍然 可以通过ZipFile对象进行访问直到调用close方法或者虚拟机退出。
See Also: Constant Field ValuesLOCSIGpublic static final long LOCSIG
See Also: Constant Field ValuesEXTSIGpublic static final long EXTSIG
See Also: Constant Field ValuesCENSIGpublic static final long CENSIG
See Also: Constant Field ValuesENDSIGpublic static final long ENDSIG
See Also: Constant Field ValuesLOCHDRpublic static final int LOCHDR
See Also: Constant Field ValuesEXTHDRpublic static final int EXTHDR
See Also: Constant Field ValuesCENHDRpublic static final int CENHDR
See Also: Constant Field ValuesENDHDRpublic static final int ENDHDR
See Also: Constant Field ValuesLOCVERpublic static final int LOCVER
See Also: Constant Field ValuesLOCFLGpublic static final int LOCFLG
See Also: Constant Field ValuesLOCHOWpublic static final int LOCHOW
See Also: Constant Field ValuesLOCTIMpublic static final int LOCTIM
See Also: Constant Field ValuesLOCCRCpublic static final int LOCCRC
See Also: Constant Field ValuesLOCSIZpublic static final int LOCSIZ
See Also: Constant Field ValuesLOCLENpublic static final int LOCLEN
See Also: Constant Field ValuesLOCNAMpublic static final int LOCNAM
See Also: Constant Field ValuesLOCEXTpublic static final int LOCEXT
See Also: Constant Field ValuesEXTCRCpublic static final int EXTCRC
See Also: Constant Field ValuesEXTSIZpublic static final int EXTSIZ
See Also: Constant Field ValuesEXTLENpublic static final int EXTLEN
See Also: Constant Field ValuesCENVEMpublic static final int CENVEM
See Also: Constant Field ValuesCENVERpublic static final int CENVER
See Also: Constant Field ValuesCENFLGpublic static final int CENFLG
See Also: Constant Field ValuesCENHOWpublic static final int CENHOW
See Also: Constant Field ValuesCENTIMpublic static final int CENTIM
See Also: Constant Field ValuesCENCRCpublic static final int CENCRC
See Also: Constant Field ValuesCENSIZpublic static final int CENSIZ
See Also: Constant Field ValuesCENLENpublic static final int CENLEN
See Also: Constant Field ValuesCENNAMpublic static final int CENNAM
See Also: Constant Field ValuesCENEXTpublic static final int CENEXT
See Also: Constant Field ValuesCENCOMpublic static final int CENCOM
See Also: Constant Field ValuesCENDSKpublic static final int CENDSK
See Also: Constant Field ValuesCENATTpublic static final int CENATT
See Also: Constant Field ValuesCENATXpublic static final int CENATX
See Also: Constant Field ValuesCENOFFpublic static final int CENOFF
See Also: Constant Field ValuesENDSUBpublic static final int ENDSUB
See Also: Constant Field ValuesENDTOTpublic static final int ENDTOT
See Also: Constant Field ValuesENDSIZpublic static final int ENDSIZ
See Also: Constant Field ValuesENDOFFpublic static final int ENDOFF
See Also: Constant Field ValuesENDCOMpublic static final int ENDCOM
See Also: Constant Field ValuesConstructor Detail
ZipFilepublic ZipFile(String name)
throws IOException
Opens a zip file for reading. 打开一个要读取的zip文件。 First, if there is a security manager, its checkRead method is called with the name argument as its argument to ensure the read is allowed. 如果存在安全管理器,首先使用name参数作为它的参数调用checkRead方法,来确认允许读取。
Parameters: name - the name of the zip file zip文件名 Throws: ZipException - if a ZIP format error has occurred 如果发生ZIP格式错误抛出 IOException - if an I/O error has occurred 如果发生I/O错误抛出 SecurityException - if a security manager exists and its checkRead method doesn't allow read access to the file. 如果安全管理器存在,它的checkRead方法不允许读取该文件时抛出。 See Also: SecurityManager.checkRead(java.lang.String)ZipFilepublic ZipFile(File file,
int mode)
throws IOException
Opens a new ZipFile to read from the specified File object in the specified mode. The mode argument must be either OPEN_READ or OPEN_READ | OPEN_DELETE. 打开一个ZipFile,按指定的模式读取指定的File对象。 First, if there is a security manager, its checkRead method is called with the name argument as its argument to ensure the read is allowed. 如果存在安全管理器,首先使用name参数作为它的参数调用checkRead方法,来确认允许读取。
Parameters: file - the ZIP file to be opened for reading 要打开读取的ZIP文件 mode - the mode in which the file is to be opened 文件要打开的模式 Throws: ZipException - if a ZIP format error has occurred 如果发生ZIP格式错误抛出 IOException - if an I/O error has occurred 如果发生I/O错误抛出 SecurityException - if a security manager exists and its checkRead method doesn't allow read access to the file, or checkDelete method doesn't allow deleting the file when OPEN_DELETE flag is set. 如果安全管理器存在且设置OPEN_DELETE标记,它的checkRead方法不允许读取该文件,或者checkDelete不允许删除该文件时抛出。 IllegalArgumentException - If the mode argument is invalid 如果mode参数无效抛出 See Also: SecurityManager.checkRead(java.lang.String)ZipFilepublic ZipFile(File file)
throws ZipException,
Opens a ZIP file for reading given the specified File object. 打开一个ZIP文件来读取指定的File对象。
Parameters: file - the ZIP file to be opened for reading 要打开读取的ZIP文件 Throws: ZipException - if a ZIP error has occurred 如果发生ZIP格式错误抛出 IOException - if an I/O error has occurred 如果发生I/O错误抛出Method Detail
getEntrypublic ZipEntry getEntry(String name)
Returns the zip file entry for the specified name, or null if not found. 返回给定名称的zip文件项,如果未找到,返回null。
Parameters: name - the name of the entry 项的名称 Returns: the zip file entry, or null if not found zip文件项,如果未找到,返回null。 Throws: IllegalStateException - if the zip file has been closed 如果zip文件已被关闭抛出getInputStreampublic InputStream getInputStream(ZipEntry entry)
throws IOException
Returns an input stream for reading the contents of the specified zip file entry. 返回读取指定zip文件项内容的输入流。 Closing this ZIP file will, in turn, close all input streams that have been returned by invocations of this method. 关闭ZIP文件,将同时关闭调用该方法返回的所有输入流。
Parameters: entry - the zip file entry zip文件项 Returns: the input stream for reading the contents of the specified zip file entry. 读取指定zip文件项内容的输入流。 Throws: ZipException - if a ZIP format error has occurred 如果发生ZIP格式错误抛出 IOException - if an I/O error has occurred 如果发生I/O错误抛出 IllegalStateException - if the zip file has been closed 如果zip文件已被关闭抛出getNamepublic String getName()
Returns the path name of the ZIP file. 返回ZIP文件的路径名。
Returns: the path name of the ZIP file ZIP文件的路径名entriespublic Enumeration entries()
Returns an enumeration of the ZIP file entries. 返回ZIP文件项的枚举。
Returns: an enumeration of the ZIP file entries ZIP文件项的枚举。 Throws: IllegalStateException - if the zip file has been closed 如果zip文件已被关闭抛出sizepublic int size()
Returns the number of entries in the ZIP file. 返回ZIP文件中项的数目。
Returns: the number of entries in the ZIP file ZIP文件中项的数目 Throws: IllegalStateException - if the zip file has been closed 如果zip文件已被关闭抛出closepublic void close()
throws IOException
Closes the ZIP file. 关闭ZIP文件。 Closing this ZIP file will close all of the input streams previously returned by invocations of the getInputStream method. 关闭ZIP文件,将同时关闭之前调用getInputStream方法返回的所有输入流。
Throws: IOException - if an I/O error has occured 如果发生I/O错误抛出finalizeprotected void finalize()
throws IOException
Ensures that the close method of this ZIP file is called when there are no more references to it. 确保没有对ZIP文件的引用时,调用close方法。 Since the time when GC would invoke this method is undetermined, it is strongly recommanded that applications invoke the close method as soon they have finished accessing this ZipFile. This will prevent holding up system resources for an undetermined length of time. 因为GC调用此方法的时间不能确定,因此强烈建议应用程序一旦完成ZipFile的访问, 立即调用close方法。这将避免长时间的占用系统资源。
Overrides: finalize in class ObjectThrows: IOException - if an I/O error occurs. 如果发生I/O错误抛出。 See Also: close()[/url][url=file:///F:/资料/文字资料/j2sdk-1_4_2-doc/docs/api/overview-summary.html]Overview
Class
JavaTM 2 Platform
Std. Ed. v1.4.2
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
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.