Name
JarInputStream
Synopsis
This class allows a JAR file to be read
from an input stream. It extends
java.util.ZipInputStream
and is used much like
that class is used. To create a JarInputStream
,
simply specify the InputStream
from which to read.
If you do not want the JarInputStream
to attempt
to verify any digital signatures contained in the JAR file, pass
false
as the second argument to the
JarInputStream( )
constructor. The
JarInputStream( )
constructor first reads the JAR
manifest entry, if one exists. The manifest must be the first entry
in the JAR file. getManifest( )
returns the
Manifest
object for the JAR file.
Once you have created a
JarInputStream
, call getNextJarEntry(
)
or getNextEntry( )
to obtain the
JarEntry
or
java.util.zip.ZipEntry
object that describes the
next entry in the JAR file. Then, call a read( )
method (including the inherited versions) to read the contents of
that entry. When the stream reaches the end of file, call
getNextJarEntry( )
again to start reading the next
entry in the file. When all entries have been read from the JAR file,
getNextJarEntry( )
and getNextEntry(
)
return null
.
Figure 16-111. java.util.jar.JarInputStream
public class JarInputStream extends java.util.zip.ZipInputStream { // Public Constructors public JarInputStream(java.io.InputStream in) throws java.io.IOException; public JarInputStream(java.io.InputStream in, boolean verify ...
Get Java in a Nutshell, 5th Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.