Home » openjdk-7 » java » util » jar » [javadoc | source]
java.util.jar
public class: JarFile [javadoc | source]
java.lang.Object
   java.util.zip.ZipFile
      java.util.jar.JarFile

All Implemented Interfaces:
    ZipConstants, Closeable

The JarFile class is used to read the contents of a jar file from any file that can be opened with java.io.RandomAccessFile. It extends the class java.util.zip.ZipFile with support for reading an optional Manifest entry. The Manifest can be used to specify meta-information about the jar file and its entries.

Unless otherwise noted, passing a null argument to a constructor or method in this class will cause a NullPointerException to be thrown.

Field Summary
public static final  String MANIFEST_NAME    The JAR manifest file name. 
Fields inherited from java.util.zip.ZipFile:
OPEN_READ,  OPEN_DELETE
Constructor:
 public JarFile(String name) throws IOException 
    Creates a new JarFile to read from the specified file name. The JarFile will be verified if it is signed.
    Parameters:
    name - the name of the jar file to be opened for reading
    Throws:
    IOException - if an I/O error has occurred
    SecurityException - if access to the file is denied by the SecurityManager
 public JarFile(File file) throws IOException 
    Creates a new JarFile to read from the specified File object. The JarFile will be verified if it is signed.
    Parameters:
    file - the jar file to be opened for reading
    Throws:
    IOException - if an I/O error has occurred
    SecurityException - if access to the file is denied by the SecurityManager
 public JarFile(String name,
    boolean verify) throws IOException 
    Creates a new JarFile to read from the specified file name.
    Parameters:
    name - the name of the jar file to be opened for reading
    verify - whether or not to verify the jar file if it is signed.
    Throws:
    IOException - if an I/O error has occurred
    SecurityException - if access to the file is denied by the SecurityManager
 public JarFile(File file,
    boolean verify) throws IOException 
    Creates a new JarFile to read from the specified File object.
    Parameters:
    file - the jar file to be opened for reading
    verify - whether or not to verify the jar file if it is signed.
    Throws:
    IOException - if an I/O error has occurred
    SecurityException - if access to the file is denied by the SecurityManager.
 public JarFile(File file,
    boolean verify,
    int mode) throws IOException 
    Creates a new JarFile to read from the specified File object in the specified mode. The mode argument must be either OPEN_READ or OPEN_READ | OPEN_DELETE.
    Parameters:
    file - the jar file to be opened for reading
    verify - whether or not to verify the jar file if it is signed.
    mode - the mode in which the file is to be opened
    Throws:
    IOException - if an I/O error has occurred
    IllegalArgumentException - if the mode argument is invalid
    SecurityException - if access to the file is denied by the SecurityManager
    since: 1.3 -
Method from java.util.jar.JarFile Summary:
entries,   entries2,   entryNames,   getCodeSource,   getCodeSources,   getEntry,   getInputStream,   getJarEntry,   getManifest,   getManifestDigests,   hasClassPathAttribute,   newEntry,   setEagerValidation
Methods from java.util.zip.ZipFile:
close,   entries,   finalize,   getComment,   getEntry,   getInputStream,   getName,   size
Methods from java.lang.Object:
clone,   equals,   finalize,   getClass,   hashCode,   notify,   notifyAll,   toString,   wait,   wait,   wait
Method from java.util.jar.JarFile Detail:
 public Enumeration<JarEntry> entries() 
    Returns an enumeration of the zip file entries.
 Enumeration<JarEntry> entries2() 
    Returns an enumeration of the zip file entries excluding internal JAR mechanism entries and including signed entries missing from the ZIP directory.
 Enumeration<String> entryNames(CodeSource[] cs) 
 CodeSource getCodeSource(URL url,
    String name) 
 CodeSource[] getCodeSources(URL url) 
 public ZipEntry getEntry(String name) 
    Returns the ZipEntry for the given entry name or null if not found.
 public synchronized InputStream getInputStream(ZipEntry ze) throws IOException 
    Returns an input stream for reading the contents of the specified zip file entry.
 public JarEntry getJarEntry(String name) 
    Returns the JarEntry for the given entry name or null if not found.
 public Manifest getManifest() throws IOException 
    Returns the jar file manifest, or null if none.
 List getManifestDigests() 
 boolean hasClassPathAttribute() throws IOException 
 JarEntry newEntry(ZipEntry ze) 
  void setEagerValidation(boolean eager)