Index (Frames) | Index (No Frames) | Package | Package Tree | Tree
java.util.jar

Class JarFile

java.lang.Object
|
+--java.util.zip.ZipFile
   |
   +--java.util.jar.JarFile


public class JarFile

extends ZipFile

Representation of a jar file.

Note that this class is not a subclass of java.io.File but a subclass of java.util.zip.ZipFile and you can only read JarFiles with it (although there are constructors that take a File object).

XXX - verification of Manifest signatures is not yet implemented.

Since:Author:

Field Summary

static java.lang.StringMANIFEST_NAME

The name of the manifest entry: META-INF/MANIFEST.MF

Constructor Summary

JarFile(java.lang.String fileName)

Creates a new JarFile.
JarFile(java.lang.String fileName, boolean verify)

Creates a new JarFile.
JarFile(java.io.File file)

Creates a new JarFile.
JarFile(java.io.File file, boolean verify)

Creates a new JarFile.
JarFile(java.io.File file, boolean verify, int mode)

Creates a new JarFile with the indicated mode.

Method Summary

java.util.Enumerationentries()

Returns a enumeration of all the entries in the JarFile.
java.util.zip.ZipEntrygetEntry(java.lang.String name)

XXX It actually returns a JarEntry not a zipEntry
synchronized java.io.InputStreamgetInputStream(java.util.zip.ZipEntry entry)

XXX should verify the inputstream
java.util.jar.JarEntrygetJarEntry(java.lang.String name)

Returns the JarEntry that belongs to the name if such an entry exists in the JarFile.
java.util.jar.ManifestgetManifest()

Returns the manifest for this JarFile or null when the JarFile does not contain a manifest file.

Field Details

MANIFEST_NAME

public static final String MANIFEST_NAME

The name of the manifest entry: META-INF/MANIFEST.MF


Constructor Details

JarFile

public JarFile(java.io.File file)

Creates a new JarFile. All jar entries are verified (when a Manifest file for this JarFile exists). You need to actually open and read the complete jar entry (with getInputStream()) to check its signature.

Parameters:

Throws:


JarFile

public JarFile(java.io.File file, boolean verify)

Creates a new JarFile. If verify is true then all jar entries are verified (when a Manifest file for this JarFile exists). You need to actually open and read the complete jar entry (with getInputStream()) to check its signature.

Parameters:

Throws:


JarFile

public JarFile(java.io.File file, boolean verify, int mode)

Creates a new JarFile with the indicated mode. If verify is true then all jar entries are verified (when a Manifest file for this JarFile exists). You need to actually open and read the complete jar entry (with getInputStream()) to check its signature. manifest and if the manifest exists and verify is true verfies it.

Since:Parameters:

Throws:


JarFile

public JarFile(java.lang.String fileName)

Creates a new JarFile. All jar entries are verified (when a Manifest file for this JarFile exists). You need to actually open and read the complete jar entry (with getInputStream()) to check its signature.

Parameters:

Throws:


JarFile

public JarFile(java.lang.String fileName, boolean verify)

Creates a new JarFile. If verify is true then all jar entries are verified (when a Manifest file for this JarFile exists). You need to actually open and read the complete jar entry (with getInputStream()) to check its signature.

Parameters:

Throws:


Method Details

entries

public Enumeration entries()

Returns a enumeration of all the entries in the JarFile. Note that also the Jar META-INF entries are returned.

Throws:


getEntry

public ZipEntry getEntry(java.lang.String name)

XXX It actually returns a JarEntry not a zipEntry

Parameters:


getInputStream

public synchronized InputStream getInputStream(java.util.zip.ZipEntry entry)

XXX should verify the inputstream

Parameters:

Throws:


getJarEntry

public JarEntry getJarEntry(java.lang.String name)

Returns the JarEntry that belongs to the name if such an entry exists in the JarFile. Returns null otherwise Convenience method that just casts the result from getEntry to a JarEntry.

Parameters:

Returns:


getManifest

public Manifest getManifest()

Returns the manifest for this JarFile or null when the JarFile does not contain a manifest file.