Stay organized with collections
Save and categorize content based on your preferences.
public
class
JarInputStream
extends 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
Inherited constants |
From class
java.util.zip.ZipInputStream
int |
CENATT
Central directory (CEN) header internal file attributes field offset.
|
int |
CENATX
Central directory (CEN) header external file attributes field offset.
|
int |
CENCOM
Central directory (CEN) header comment length field offset.
|
int |
CENCRC
Central directory (CEN) header uncompressed file crc-32 value field offset.
|
int |
CENDSK
Central directory (CEN) header disk number start field offset.
|
int |
CENEXT
Central directory (CEN) header extra field length field offset.
|
int |
CENFLG
Central directory (CEN) header encrypt, decrypt flags field offset.
|
int |
CENHDR
Central directory (CEN) header size in bytes (including signature).
|
int |
CENHOW
Central directory (CEN) header compression method field offset.
|
int |
CENLEN
Central directory (CEN) header uncompressed size field offset.
|
int |
CENNAM
Central directory (CEN) header filename length field offset.
|
int |
CENOFF
Central directory (CEN) header LOC header offset field offset.
|
long |
CENSIG
Central directory (CEN) header signature.
|
int |
CENSIZ
Central directory (CEN) header compressed size field offset.
|
int |
CENTIM
Central directory (CEN) header modification time field offset.
|
int |
CENVEM
Central directory (CEN) header version made by field offset.
|
int |
CENVER
Central directory (CEN) header version needed to extract field offset.
|
int |
ENDCOM
End of central directory (END) header zip file comment length field offset.
|
int |
ENDHDR
End of central directory (END) header size in bytes (including signature).
|
int |
ENDOFF
End of central directory (END) header offset for the first CEN header field offset.
|
long |
ENDSIG
End of central directory (END) header signature.
|
int |
ENDSIZ
End of central directory (END) header central directory size in bytes field offset.
|
int |
ENDSUB
End of central directory (END) header number of entries on this disk field offset.
|
int |
ENDTOT
End of central directory (END) header total number of entries field offset.
|
int |
EXTCRC
Extra local (EXT) header uncompressed file crc-32 value field offset.
|
int |
EXTHDR
Extra local (EXT) header size in bytes (including signature).
|
int |
EXTLEN
Extra local (EXT) header uncompressed size field offset.
|
long |
EXTSIG
Extra local (EXT) header signature.
|
int |
EXTSIZ
Extra local (EXT) header compressed size field offset.
|
int |
LOCCRC
Local file (LOC) header uncompressed file crc-32 value field offset.
|
int |
LOCEXT
Local file (LOC) header extra field length field offset.
|
int |
LOCFLG
Local file (LOC) header general purpose bit flag field offset.
|
int |
LOCHDR
Local file (LOC) header size in bytes (including signature).
|
int |
LOCHOW
Local file (LOC) header compression method field offset.
|
int |
LOCLEN
Local file (LOC) header uncompressed size field offset.
|
int |
LOCNAM
Local file (LOC) header filename length field offset.
|
long |
LOCSIG
Local file (LOC) header signature.
|
int |
LOCSIZ
Local file (LOC) header compressed size field offset.
|
int |
LOCTIM
Local file (LOC) header modification time field offset.
|
int |
LOCVER
Local file (LOC) header version needed to extract field offset.
|
|
Inherited fields |
From class
java.util.zip.InflaterInputStream
protected
byte[] |
buf
Input buffer for decompression.
|
protected
boolean |
closed
This field was deprecated
in API level 29.
This field will be removed from a future version of Android and should not be
used. Subclasses that access this field need to be modified to keep track of their own
closed state by overriding close().
|
protected
Inflater |
inf
Decompressor for this stream.
|
protected
int |
len
Length of input buffer.
|
|
|
|
Public methods |
Manifest
|
getManifest()
Returns the Manifest for this JAR file, or
null if none.
|
ZipEntry
|
getNextEntry()
Reads the next ZIP file entry and positions the stream at the
beginning of the entry data.
|
JarEntry
|
getNextJarEntry()
Reads the next JAR file entry and positions the stream at the
beginning of the entry data.
|
int
|
read(byte[] b, int off, int len)
Reads from the current JAR file entry into an array of bytes.
|
Inherited methods |
From class
java.util.zip.ZipInputStream
int
|
available()
Returns 0 after EOF has reached for the current entry data,
otherwise always return 1.
|
void
|
close()
Closes this input stream and releases any system resources associated
with the stream.
|
void
|
closeEntry()
Closes the current ZIP entry and positions the stream for reading the
next entry.
|
ZipEntry
|
createZipEntry(String name)
Creates a new ZipEntry object for the specified
entry name.
|
ZipEntry
|
getNextEntry()
Reads the next ZIP file entry and positions the stream at the
beginning of the entry data.
|
int
|
read(byte[] b, int off, int len)
Reads from the current ZIP entry into an array of bytes.
|
long
|
skip(long n)
Skips specified number of bytes in the current ZIP entry.
|
|
From class
java.util.zip.InflaterInputStream
int
|
available()
Returns 0 after EOF has been reached, otherwise always return 1.
|
void
|
close()
Closes this input stream and releases any system resources associated
with the stream.
|
void
|
fill()
Fills input buffer with more data to decompress.
|
void
|
mark(int readlimit)
Marks the current position in this input stream.
|
boolean
|
markSupported()
Tests if this input stream supports the mark and
reset methods.
|
int
|
read()
Reads a byte of uncompressed data.
|
int
|
read(byte[] b, int off, int len)
Reads uncompressed data into an array of bytes.
|
void
|
reset()
Repositions this stream to the position at the time the
mark method was last called on this input stream.
|
long
|
skip(long n)
Skips specified number of bytes of uncompressed data.
|
|
From class
java.io.FilterInputStream
int
|
available()
Returns an estimate of the number of bytes that can be read (or
skipped over) from this input stream without blocking by the next
caller of a method for this input stream.
|
void
|
close()
Closes this input stream and releases any system resources
associated with the stream.
|
void
|
mark(int readlimit)
Marks the current position in this input stream.
|
boolean
|
markSupported()
Tests if this input stream supports the mark
and reset methods.
|
int
|
read()
Reads the next byte of data from this input stream.
|
int
|
read(byte[] b, int off, int len)
Reads up to len bytes of data from this input stream
into an array of bytes.
|
int
|
read(byte[] b)
Reads up to b.length bytes of data from this
input stream into an array of bytes.
|
void
|
reset()
Repositions this stream to the position at the time the
mark method was last called on this input stream.
|
long
|
skip(long n)
Skips over and discards n bytes of data from the
input stream.
|
|
From class
java.io.InputStream
int
|
available()
Returns an estimate of the number of bytes that can be read (or skipped
over) from this input stream without blocking, which may be 0, or 0 when
end of stream is detected.
|
void
|
close()
Closes this input stream and releases any system resources associated
with the stream.
|
void
|
mark(int readlimit)
Marks the current position in this input stream.
|
boolean
|
markSupported()
Tests if this input stream supports the mark and
reset methods.
|
static
InputStream
|
nullInputStream()
Returns a new InputStream that reads no bytes.
|
int
|
read(byte[] b)
Reads some number of bytes from the input stream and stores them into
the buffer array b.
|
abstract
int
|
read()
Reads the next byte of data from the input stream.
|
int
|
read(byte[] b, int off, int len)
Reads up to len bytes of data from the input stream into
an array of bytes.
|
byte[]
|
readAllBytes()
Reads all remaining bytes from the input stream.
|
int
|
readNBytes(byte[] b, int off, int len)
Reads the requested number of bytes from the input stream into the given
byte array.
|
byte[]
|
readNBytes(int len)
Reads up to a specified number of bytes from the input stream.
|
void
|
reset()
Repositions this stream to the position at the time the
mark method was last called on this input stream.
|
long
|
skip(long n)
Skips over and discards n bytes of data from this input
stream.
|
void
|
skipNBytes(long n)
Skips over and discards exactly n bytes of data from this input
stream.
|
long
|
transferTo(OutputStream out)
Reads all bytes from this input stream and writes the bytes to the
given output stream in the order that they are read.
|
|
From class
java.lang.Object
Object
|
clone()
Creates and returns a copy of this object.
|
boolean
|
equals(Object obj)
Indicates whether some other object is "equal to" this one.
|
void
|
finalize()
Called by the garbage collector on an object when garbage collection
determines that there are no more references to the object.
|
final
Class<?>
|
getClass()
Returns the runtime class of this Object.
|
int
|
hashCode()
Returns a hash code value for the object.
|
final
void
|
notify()
Wakes up a single thread that is waiting on this object's
monitor.
|
final
void
|
notifyAll()
Wakes up all threads that are waiting on this object's monitor.
|
String
|
toString()
Returns a string representation of the object.
|
final
void
|
wait(long timeoutMillis, int nanos)
Causes the current thread to wait until it is awakened, typically
by being notified or interrupted, or until a
certain amount of real time has elapsed.
|
final
void
|
wait(long timeoutMillis)
Causes the current thread to wait until it is awakened, typically
by being notified or interrupted, or until a
certain amount of real time has elapsed.
|
final
void
|
wait()
Causes the current thread to wait until it is awakened, typically
by being notified or interrupted.
|
|
From interface
java.io.Closeable
abstract
void
|
close()
Closes this stream and releases any system resources associated
with it.
|
|
|
|
Public constructors
public JarInputStream (InputStream in)
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.
| Parameters |
in |
InputStream: the actual input stream |
public JarInputStream (InputStream in,
boolean verify)
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. |
Public methods
getManifest
public Manifest getManifest ()
Returns the Manifest for this JAR file, or
null if none.
| Returns |
Manifest |
the Manifest for this JAR file, or
null if none. |
getNextEntry
public ZipEntry getNextEntry ()
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.
| Returns |
ZipEntry |
the next ZIP file entry, or null if there are no more entries |
getNextJarEntry
public JarEntry getNextJarEntry ()
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.
| Returns |
JarEntry |
the next JAR file entry, or null if there are no more entries |
read
public int read (byte[] b,
int off,
int len)
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 |
byte: 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 |
| Returns |
int |
the actual number of bytes read, or -1 if the end of the
entry is reached |
Protected methods
createZipEntry
protected ZipEntry createZipEntry (String name)
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 |
| Returns |
ZipEntry |
the JarEntry object just created |
Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
Last updated 2026-06-23 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2026-06-23 UTC."],[],[]]