Name
JarFile
Synopsis
This class
represents a JAR file and allows the manifest, file list, and
individual files to be read from the JAR file. It extends
java.util.zip.ZipFile, and its use is similar to
that of its superclass. Create a JarFile by
specifying a filename or File object. If you do
not want JarFile to attempt to verify any digital
signatures contained in the JarFile, pass an
optional boolean argument of false to the
JarFile( ) constructor. As of Java 1.3, temporary
JAR files can be automatically deleted when they are closed. To take
advantage of this feature, pass
ZipFile.OPEN_READ|ZipFile.OPEN_DELETE as the
mode argument to the JarFile(
) constructor.
Once you
have created a JarFile object, obtain the JAR
Manifest with getManifest( ).
Obtain an enumeration of the
java.util.zip.ZipEntry objects in the file with
entries( ). Get the JarEntry
for a specified file in the JAR file with getJarEntry(
). To read the contents of a specific entry in the JAR
file, obtain the JarEntry or
ZipEntry object that represents that entry, pass
it to getInputStream( ), and then read until the
end of that stream. JarFile does not support the
creation of new JAR files or the modification of existing files.
Figure 16-110. java.util.jar.JarFile
public class JarFile extends java.util.zip.ZipFile { // Public Constructors public JarFile(String name) throws java.io.IOException; public JarFile(java.io.File ...