| |||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
File file = …;
JarFile jarFile = new JarFile(file);
Based on 60 examples
public class JarFile extends ZipFile
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 {@link NullPointerException} to be thrown.
Field Summary | |
---|---|
static String |
MANIFEST_NAME
The JAR manifest file name. |
Fields inherited from class java.util.zip.ZipFile |
---|
OPEN_DELETE, OPEN_READ |
Constructor Summary | |
---|---|
Creates a new JarFile to read from the specified
File object.
|
|
Creates a new JarFile to read from the specified
File object.
|
|
Creates a new JarFile to read from the specified
File object in the specified mode.
|
|
Creates a new JarFile to read from the specified
file name .
|
|
Creates a new JarFile to read from the specified
file name .
|
Method Summary | |
---|---|
Enumeration |
entries() Returns an enumeration of the zip file entries. |
ZipEntry |
Returns the ZipEntry for the given entry name or
null if not found.
|
InputStream |
Returns an input stream for reading the contents of the specified zip file entry. |
JarEntry |
getJarEntry(String name) Returns the JarEntry for the given entry name or
null if not found.
|
Manifest |
Returns the jar file manifest, or null if none.
|
Methods inherited from class java.util.zip.ZipFile |
---|
close, entries, finalize, getEntry, getInputStream, getName, size |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final String MANIFEST_NAME
Constructor Detail |
---|
public JarFile(File file) throws IOException
JarFile
to read from the specified
File
object. The JarFile
will be verified if
it is signed.
file
- the jar file to be opened for readingIOException
- if an I/O error has occurredpublic JarFile(File file, boolean verify) throws IOException
JarFile
to read from the specified
File
object.
file
- the jar file to be opened for readingverify
- whether or not to verify the jar file if
it is signed.IOException
- if an I/O error has occurredpublic JarFile(File file, boolean verify, int mode) throws IOException
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.
file
- the jar file to be opened for readingverify
- whether or not to verify the jar file if
it is signed.mode
- the mode in which the file is to be openedIOException
- if an I/O error has occurredpublic JarFile(String name) throws IOException
JarFile
to read from the specified
file name
. The JarFile
will be verified if
it is signed.
name
- the name of the jar file to be opened for readingIOException
- if an I/O error has occurredpublic JarFile(String name, boolean verify) throws IOException
JarFile
to read from the specified
file name
.
name
- the name of the jar file to be opened for readingverify
- whether or not to verify the jar file if
it is signed.IOException
- if an I/O error has occurredMethod Detail |
---|
public Enumeration entries()
entries
in class ZipFile
public ZipEntry getEntry(String name)
ZipEntry
for the given entry name or
null
if not found.
getEntry
in class ZipFile
name
- the jar file entry nameZipEntry
for the given entry name or
null
if not foundpublic synchronized InputStream getInputStream(ZipEntry ze) throws IOException
getInputStream
in class ZipFile
ze
- the zip file entryIOException
- if an I/O error has occurredpublic JarEntry getJarEntry(String name)
JarEntry
for the given entry name or
null
if not found.
name
- the jar file entry nameJarEntry
for the given entry name or
null
if not found.public Manifest getManifest() throws IOException
null
if none.
null
if noneIOException
| |||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |