Build 1.0_r1(from source)

java.util.jar
Class JarFile

java.lang.Object
  extended by java.util.zip.ZipFile
      extended by java.util.jar.JarFile
All Implemented Interfaces:
ZipConstants

public class JarFile
extends ZipFile

JarFile is used to read jar entries and their associated data from jar files.

See Also:
JarInputStream, JarEntry

Nested Class Summary
(package private) static class JarFile.JarFileInputStream
           
 
Field Summary
static String MANIFEST_NAME
           
(package private) static String META_DIR
           
(package private)  JarVerifier verifier
           
 
Fields inherited from class java.util.zip.ZipFile
OPEN_DELETE, OPEN_READ
 
Fields inherited from interface java.util.zip.ZipConstants
CENATT, CENATX, CENCOM, CENCRC, CENDSK, CENEXT, CENFLG, CENHDR, CENHOW, CENLEN, CENNAM, CENOFF, CENSIG, CENSIZ, CENTIM, CENVEM, CENVER, ENDCOM, ENDHDR, ENDOFF, ENDSIG, ENDSIZ, ENDSUB, ENDTOT, EXTCRC, EXTHDR, EXTLEN, EXTSIG, EXTSIZ, LOCCRC, LOCEXT, LOCFLG, LOCHDR, LOCHOW, LOCLEN, LOCNAM, LOCSIG, LOCSIZ, LOCTIM, LOCVER
 
Constructor Summary
JarFile(File file)
          Create a new JarFile using the contents of file.
JarFile(File file, boolean verify)
          Create a new JarFile using the contents of file.
JarFile(File file, boolean verify, int mode)
          Create a new JarFile using the contents of file.
JarFile(String filename)
          Create a new JarFile from the contents of the file specified by filename.
JarFile(String filename, boolean verify)
          Create a new JarFile from the contents of the file specified by filename.
 
Method Summary
 void close()
          Close the Zip file.
 Enumeration<JarEntry> entries()
          Return an enumeration containing the JarEntrys contained in this JarFile.
 ZipEntry getEntry(String name)
          Return the JarEntry specified by name or null if no such entry exists
 InputStream getInputStream(ZipEntry ze)
          Return an InputStream for reading the decompressed contents of ze.
 JarEntry getJarEntry(String name)
          Return the JarEntry specified by name or null if no such entry exists.
 Manifest getManifest()
          Returns the Manifest object associated with this JarFile or null if no manifest entry exists.
 
Methods inherited from class java.util.zip.ZipFile
finalize, getName, size
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MANIFEST_NAME

public static final String MANIFEST_NAME
See Also:
Constant Field Values

META_DIR

static final String META_DIR
See Also:
Constant Field Values

verifier

JarVerifier verifier
Constructor Detail

JarFile

public JarFile(File file)
        throws IOException
Create a new JarFile using the contents of file.

Parameters:
file - java.io.File
Throws:
IOException - If the file cannot be read.

JarFile

public JarFile(File file,
               boolean verify)
        throws IOException
Create a new JarFile using the contents of file.

Parameters:
file - java.io.File
verify - verify a signed jar file
Throws:
IOException - If the file cannot be read.

JarFile

public JarFile(File file,
               boolean verify,
               int mode)
        throws IOException
Create a new JarFile using the contents of file.

Parameters:
file - java.io.File
verify - verify a signed jar file
mode - the mode to use, either OPEN_READ or OPEN_READ | OPEN_DELETE
Throws:
IOException - If the file cannot be read.

JarFile

public JarFile(String filename)
        throws IOException
Create a new JarFile from the contents of the file specified by filename.

Parameters:
filename - java.lang.String
Throws:
IOException - If fileName cannot be opened for reading.

JarFile

public JarFile(String filename,
               boolean verify)
        throws IOException
Create a new JarFile from the contents of the file specified by filename.

Parameters:
filename - java.lang.String
verify - verify a signed jar file
Throws:
IOException - If fileName cannot be opened for reading.
Method Detail

entries

public Enumeration<JarEntry> entries()
Return an enumeration containing the JarEntrys contained in this JarFile.

Overrides:
entries in class ZipFile
Returns:
java.util.Enumeration
Throws:
IllegalStateException - If this JarFile has been closed.

getJarEntry

public JarEntry getJarEntry(String name)
Return the JarEntry specified by name or null if no such entry exists.

Parameters:
name - the name of the entry in the jar file
Returns:
java.util.jar.JarEntry

getManifest

public Manifest getManifest()
                     throws IOException
Returns the Manifest object associated with this JarFile or null if no manifest entry exists.

Returns:
java.util.jar.Manifest
Throws:
IOException

getInputStream

public InputStream getInputStream(ZipEntry ze)
                           throws IOException
Return an InputStream for reading the decompressed contents of ze.

Overrides:
getInputStream in class ZipFile
Parameters:
ze - the ZipEntry to read from
Returns:
java.io.InputStream
Throws:
IOException - If an error occured while creating the InputStream.

getEntry

public ZipEntry getEntry(String name)
Return the JarEntry specified by name or null if no such entry exists

Overrides:
getEntry in class ZipFile
Parameters:
name - the name of the entry in the jar file
Returns:
java.util.jar.JarEntry

close

public void close()
           throws IOException
Description copied from class: ZipFile
Close the Zip file. This could be called multiple times, e.g. once explicitly and again by the finalizer. The Java doc doesn't say anything about what operations like entries() or getName() are supposed to do after the file is closed.

Overrides:
close in class ZipFile
Throws:
IOException

Build 1.0_r1(from source)

Please submit a feedback, bug or feature