java.util.zip
Class ZipFile
java.lang.Object
|
+--java.util.zip.ZipFile
All Implemented Interfaces:
java.util.zip.ZipConstants
public class
ZipFileextends
Objectimplements java.util.zip.ZipConstants
This class represents a Zip archive. You can ask for the contained
entries, or get an input stream for a file entry. The entry is
automatically decompressed.
This class is thread safe: You can open input streams for arbitrary
entries in different threads.
Authors:- Jochen Hoenicke
- Artur Biesiadowski
OPEN_DELETE
public static final int OPEN_DELETE
Mode flag to delete a zip file after reading.
OPEN_READ
public static final int OPEN_READ
Mode flag to open a zip file for reading.
ZipFile
public ZipFile(java.io.File file)
Opens a Zip file reading the given File.
Parameters:
Throws:
ZipFile
public ZipFile(java.io.File file, int mode)
Opens a Zip file reading the given File in the given mode.
If the OPEN_DELETE mode is specified, the zip file will be deleted at
some time moment after it is opened. It will be deleted before the zip
file is closed or the Virtual Machine exits.
The contents of the zip file will be accessible until it is closed.
The OPEN_DELETE mode is currently unimplemented in this library
Since:Parameters:
Throws:
ZipFile
public ZipFile(java.lang.String name)
Opens a Zip file with the given name for reading.
Parameters:
Throws:
close
public void close()
Closes the ZipFile. This also closes all input streams given by
this class. After this is called, no further method should be
called.
Throws:
entries
public Enumeration entries()
Returns an enumeration of all Zip entries in this Zip file.
getEntry
public ZipEntry getEntry(java.lang.String name)
Searches for a zip entry in this archive with the given name.
Parameters:
Returns:
- the zip entry, or null if no entry with that name exists.
getInputStream
public InputStream getInputStream(java.util.zip.ZipEntry entry)
Creates an input stream reading the given zip entry as
uncompressed data. Normally zip entry should be an entry
returned by getEntry() or entries().
Parameters:
Returns:
Throws:
getName
public String getName()
Returns the name of this zip file.
size
public int size()
Returns the number of entries in this zip file.