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_READZipFile.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.JarFilepublic class JarFile extends java.util.zip.ZipFile { // Public Constructors public JarFile (String name ) throws java.io.IOException; public JarFile (java.io.File file ) throws java.io.IOException; public JarFile (String name , boolean verify ) throws java.io.IOException; public JarFile (java.io.File file , boolean verify ) throws java.io.IOException; 1.3 public JarFile (java.io.File file , boolean verify , int mode ) throws java.io.IOException; // Public Constants public static final String MANIFEST_NAME ; = "META-INF/MANIFEST.MF" // Public Instance Methods public JarEntry getJarEntry (String name ); public Manifest getManifest ( ) throws java.io.IOException; // Public Methods Overriding ZipFile public java.util.Enumeration<JarEntry> entries ( ); public java.util.zip.ZipEntry getEntry (String name ); public java.io.InputStream getInputStream (java.util.zip.ZipEntry ze ) throws java.io.IOException; synchronized } Passed ToPack200.Packer.pack( ) Returned Byjava.net.JarURLConnection.getJarFile( ) |