| |
|
| java.lang.Object java.util.zip.ZipFile
All known Subclasses: java.util.jar.JarFile,
ZipFile | public class ZipFile implements ZipConstants(Code) | | This class is used to read entries from a zip file.
Unless otherwise noted, passing a null argument to a constructor
or method in this class will cause a
NullPointerException to be
thrown.
version: 1.84, 05/05/07 author: David Connelly |
Field Summary | |
final public static int | OPEN_DELETE Mode flag to open a zip file and mark it for deletion. | final public static int | OPEN_READ Mode flag to open a zip file for reading. |
Constructor Summary | |
public | ZipFile(String name) Opens a zip file for reading. | public | ZipFile(File file, int mode) Opens a new ZipFile to read from the specified
File object in the specified mode. | public | ZipFile(File file) Opens a ZIP file for reading given the specified File object. |
Method Summary | |
public void | close() Closes the ZIP file. | public Enumeration<? extends ZipEntry> | entries() Returns an enumeration of the ZIP file entries. | protected void | finalize() Ensures that the close method of this ZIP file is
called when there are no more references to it. | public ZipEntry | getEntry(String name) Returns the zip file entry for the specified name, or null
if not found. | public InputStream | getInputStream(ZipEntry entry) Returns an input stream for reading the contents of the specified
zip file entry. | public String | getName() Returns the path name of the ZIP file. | public int | size() Returns the number of entries in the ZIP file. |
OPEN_DELETE | final public static int OPEN_DELETE(Code) | | 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.
|
OPEN_READ | final public static int OPEN_READ(Code) | | Mode flag to open a zip file for reading.
|
ZipFile | public ZipFile(String name) throws IOException(Code) | | Opens a zip file for reading.
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.
Parameters: name - the name of the zip file throws: ZipException - if a ZIP format error has occurred throws: IOException - if an I/O error has occurred throws: SecurityException - if a security manager exists and itscheckRead method doesn't allow read access to the file. See Also: SecurityManager.checkRead(java.lang.String) |
ZipFile | public ZipFile(File file, int mode) throws IOException(Code) | | 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.
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.
Parameters: file - the ZIP file to be opened for reading Parameters: mode - the mode in which the file is to be opened throws: ZipException - if a ZIP format error has occurred throws: IOException - if an I/O error has occurred throws: SecurityException - if a security manager exists andits checkRead methoddoesn't allow read access to the file,or its checkDelete method doesn't allow deletingthe file when the OPEN_DELETE flag is set. throws: IllegalArgumentException - if the mode argument is invalid See Also: SecurityManager.checkRead(java.lang.String) since: 1.3 |
ZipFile | public ZipFile(File file) throws ZipException, IOException(Code) | | Opens a ZIP file for reading given the specified File object.
Parameters: file - the ZIP file to be opened for reading throws: ZipException - if a ZIP error has occurred throws: IOException - if an I/O error has occurred |
close | public void close() throws IOException(Code) | | Closes the ZIP file.
Closing this ZIP file will close all of the input streams
previously returned by invocations of the
ZipFile.getInputStreamgetInputStream method.
throws: IOException - if an I/O error has occurred |
finalize | protected void finalize() throws IOException(Code) | | Ensures that the close method of this ZIP file is
called when there are no more references to it.
Since the time when GC would invoke this method is undetermined,
it is strongly recommended 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.
throws: IOException - if an I/O error has occurred See Also: java.util.zip.ZipFile.close |
getEntry | public ZipEntry getEntry(String name)(Code) | | Returns the zip file entry for the specified name, or null
if not found.
Parameters: name - the name of the entry the zip file entry, or null if not found throws: IllegalStateException - if the zip file has been closed |
getInputStream | public InputStream getInputStream(ZipEntry entry) throws IOException(Code) | | Returns an input stream for reading the contents of the specified
zip file entry.
Closing this ZIP file will, in turn, close all input
streams that have been returned by invocations of this method.
Parameters: entry - the zip file entry the input stream for reading the contents of the specifiedzip file entry. throws: ZipException - if a ZIP format error has occurred throws: IOException - if an I/O error has occurred throws: IllegalStateException - if the zip file has been closed |
getName | public String getName()(Code) | | Returns the path name of the ZIP file.
the path name of the ZIP file |
size | public int size()(Code) | | Returns the number of entries in the ZIP file.
the number of entries in the ZIP file throws: IllegalStateException - if the zip file has been closed |
|
|
|