open class JarInputStream : ZipInputStream
The JarInputStream class is used to read the contents of a JAR file from any input stream. It extends the class java.util.zip.ZipInputStream with support for reading an optional Manifest entry. The Manifest can be used to store meta-information about the JAR file and its entries.
Summary
| Public constructors |
|
Creates a new JarInputStream and reads the optional manifest.
|
|
Creates a new JarInputStream and reads the optional manifest.
|
| Public methods |
| open Manifest! |
Returns the Manifest for this JAR file, or null if none.
|
| open ZipEntry! |
Reads the next ZIP file entry and positions the stream at the beginning of the entry data.
|
| open JarEntry! |
Reads the next JAR file entry and positions the stream at the beginning of the entry data.
|
| open Int |
Reads from the current JAR file entry into an array of bytes.
|
| Protected methods |
| open ZipEntry! |
Creates a new JarEntry (ZipEntry) for the specified JAR file entry name.
|
| Inherited functions |
From class ZipInputStream
Int |
available()
Returns 0 after EOF has reached for the current entry data, otherwise always return 1.
Programs should not count on this method to return the actual number of bytes that could be read without blocking.
|
Unit |
close()
Closes this input stream and releases any system resources associated with the stream.
|
Unit |
closeEntry()
Closes the current ZIP entry and positions the stream for reading the next entry.
|
Long |
skip(n: Long)
Skips specified number of bytes in the current ZIP entry.
|
|
From class InflaterInputStream
Unit |
fill()
Fills input buffer with more data to decompress.
|
Unit |
mark(readlimit: Int)
Marks the current position in this input stream.
The mark method of InflaterInputStream does nothing.
|
Boolean |
markSupported()
Tests if this input stream supports the mark and reset methods. The markSupported method of InflaterInputStream returns false.
|
Int |
read()
Reads a byte of uncompressed data. This method will block until enough input is available for decompression.
|
Unit |
reset()
Repositions this stream to the position at the time the mark method was last called on this input stream.
The method reset for class InflaterInputStream does nothing except throw an IOException.
|
|
From class FilterInputStream
Int |
read(b: ByteArray!)
Reads up to byte.length bytes of data from this input stream into an array of bytes. This method blocks until some input is available.
This method simply performs the call read(b, 0, b.length) and returns the result. It is important that it does not do in.read(b) instead; certain subclasses of FilterInputStream depend on the implementation strategy actually used.
|
|
Constants
CENATT
static val CENATT: Int
Value: 36
CENATX
static val CENATX: Int
Value: 38
CENCOM
static val CENCOM: Int
Value: 32
CENCRC
static val CENCRC: Int
Value: 16
CENDSK
static val CENDSK: Int
Value: 34
CENEXT
static val CENEXT: Int
Value: 30
CENFLG
static val CENFLG: Int
Value: 8
CENHDR
static val CENHDR: Int
Value: 46
CENHOW
static val CENHOW: Int
Value: 10
CENLEN
static val CENLEN: Int
Value: 24
CENNAM
static val CENNAM: Int
Value: 28
CENOFF
static val CENOFF: Int
Value: 42
CENSIG
static val CENSIG: Long
Value: 33639248L
CENSIZ
static val CENSIZ: Int
Value: 20
CENTIM
static val CENTIM: Int
Value: 12
CENVEM
static val CENVEM: Int
Value: 4
CENVER
static val CENVER: Int
Value: 6
ENDCOM
static val ENDCOM: Int
Value: 20
ENDHDR
static val ENDHDR: Int
Value: 22
ENDOFF
static val ENDOFF: Int
Value: 16
ENDSIG
static val ENDSIG: Long
Value: 101010256L
ENDSIZ
static val ENDSIZ: Int
Value: 12
ENDSUB
static val ENDSUB: Int
Value: 8
ENDTOT
static val ENDTOT: Int
Value: 10
EXTCRC
static val EXTCRC: Int
Value: 4
EXTHDR
static val EXTHDR: Int
Value: 16
EXTLEN
static val EXTLEN: Int
Value: 12
EXTSIG
static val EXTSIG: Long
Value: 134695760L
EXTSIZ
static val EXTSIZ: Int
Value: 8
LOCCRC
static val LOCCRC: Int
Value: 14
LOCEXT
static val LOCEXT: Int
Value: 28
LOCFLG
static val LOCFLG: Int
Value: 6
LOCHDR
static val LOCHDR: Int
Value: 30
LOCHOW
static val LOCHOW: Int
Value: 8
LOCLEN
static val LOCLEN: Int
Value: 22
LOCNAM
static val LOCNAM: Int
Value: 26
LOCSIG
static val LOCSIG: Long
Value: 67324752L
LOCSIZ
static val LOCSIZ: Int
Value: 18
LOCTIM
static val LOCTIM: Int
Value: 10
LOCVER
static val LOCVER: Int
Value: 4
Public constructors
<init>
JarInputStream(in: InputStream!)
Creates a new JarInputStream and reads the optional manifest. If a manifest is present, also attempts to verify the signatures if the JarInputStream is signed.
| Exceptions |
java.io.IOException |
if an I/O error has occurred |
<init>
JarInputStream(
in: InputStream!,
verify: Boolean)
Creates a new JarInputStream and reads the optional manifest. If a manifest is present and verify is true, also attempts to verify the signatures if the JarInputStream is signed.
| Parameters |
in |
InputStream!: the actual input stream |
verify |
Boolean: whether or not to verify the JarInputStream if it is signed. |
| Exceptions |
java.io.IOException |
if an I/O error has occurred |
Public methods
getManifest
open fun getManifest(): Manifest!
Returns the Manifest for this JAR file, or null if none.
| Return |
Manifest! |
the Manifest for this JAR file, or null if none. |
getNextEntry
open fun getNextEntry(): ZipEntry!
Reads the next ZIP file entry and positions the stream at the beginning of the entry data. If verification has been enabled, any invalid signature detected while positioning the stream for the next entry will result in an exception.
| Return |
ZipEntry! |
the next ZIP file entry, or null if there are no more entries |
| Exceptions |
java.util.zip.ZipException |
if a ZIP file error has occurred |
java.io.IOException |
if an I/O error has occurred |
java.lang.SecurityException |
if any of the jar file entries are incorrectly signed. |
getNextJarEntry
open fun getNextJarEntry(): JarEntry!
Reads the next JAR file entry and positions the stream at the beginning of the entry data. If verification has been enabled, any invalid signature detected while positioning the stream for the next entry will result in an exception.
| Return |
JarEntry! |
the next JAR file entry, or null if there are no more entries |
| Exceptions |
java.util.zip.ZipException |
if a ZIP file error has occurred |
java.io.IOException |
if an I/O error has occurred |
java.lang.SecurityException |
if any of the jar file entries are incorrectly signed. |
read
open fun read(
b: ByteArray!,
off: Int,
len: Int
): Int
Reads from the current JAR file entry into an array of bytes. If len is not zero, the method blocks until some input is available; otherwise, no bytes are read and 0 is returned. If verification has been enabled, any invalid signature on the current entry will be reported at some point before the end of the entry is reached.
| Parameters |
b |
ByteArray!: the buffer into which the data is read |
off |
Int: the start offset in the destination array b |
len |
Int: the maximum number of bytes to read |
| Return |
Int |
the actual number of bytes read, or -1 if the end of the entry is reached |
| Exceptions |
java.lang.NullPointerException |
If b is null. |
java.lang.IndexOutOfBoundsException |
If off is negative, len is negative, or len is greater than b.length - off |
java.util.zip.ZipException |
if a ZIP file error has occurred |
java.io.IOException |
if an I/O error has occurred |
java.lang.SecurityException |
if any of the jar file entries are incorrectly signed. |
Protected methods
createZipEntry
protected open fun createZipEntry(name: String!): ZipEntry!
Creates a new JarEntry (ZipEntry) for the specified JAR file entry name. The manifest attributes of the specified JAR file entry name will be copied to the new JarEntry.
| Parameters |
name |
String!: the name of the JAR/ZIP file entry |
| Return |
ZipEntry! |
the JarEntry object just created |