JarInputStream is a subclass of ZipInputStream that reads data from JAR archives.

public class JarInputStream extends ZipInputStream

Two constructors chain the JAR input stream to an underlying input stream:

public JarInputStream(InputStream in) throws IOException
public JarInputStream(InputStream in, boolean verify) throws IOException

By default, any signatures present in the JAR archive will be verified, and an IOException will be thrown if verification fails. However, you can turn off this behavior by passing false as the second argument to the constructor. For example:

FileInputStream fin = new FileInputStream("javaio.jar");
JarInputStream jin = new JarInputStream(fin, false);

When the JarInputStream object is constructed, the manifest, if present, is read from the stream and stored inside the class as a Manifest object. You do not get an opportunity to read the manifest from the stream yourself. However, you can retrieve the Manifest object with the getManifest( ) method:

public Manifest getManifest( )

Otherwise, a JAR input stream is used almost exactly like a zip input stream. You position the stream on a particular entry in the file and read data from it using the normal read( ) methods. Any necessary decompression is performed transparently. When you've finished reading an entry, you close it and position the stream on the next entry. Two methods, getNextEntry( ) and read( ), are overridden so that verification of signatures can be performed. A getNextJarEntry( ) method that returns a JarEntry instead of a ZipEntry is also available. This method can be used in place of getNextEnTRy( ), if you like:

public ZipEntry getNextEntry( ) throws IOException
public int read(byte[] data, int offset, int length) throws IOException
public JarEntry getNextJarEntry( ) throws IOException

Basic I/O

Introducing I/O

Output Streams

Input Streams

Data Sources

File Streams

Network Streams

Filter Streams

Filter Streams

Print Streams

Data Streams

Streams in Memory

Compressing Streams

JAR Archives

Cryptographic Streams

Object Serialization

New I/O



Nonblocking I/O

The File System

Working with Files

File Dialogs and Choosers


Character Sets and Unicode

Readers and Writers

Formatted I/O with java.text


The Java Communications API


The J2ME Generic Connection Framework


Character Sets

Java I/O
Java I/O
ISBN: 0596527500
EAN: 2147483647
Year: 2004
Pages: 244

Flylib.com © 2008-2020.
If you may any questions please contact us: flylib@qtcs.net