- java.lang.Object
- 
- java.io.InputStream
- 
- java.io.FilterInputStream
- 
- java.util.zip.InflaterInputStream
- 
- java.util.zip.ZipInputStream
- 
- java.util.jar.JarInputStream
 
 
 
 
 
- 
- All Implemented Interfaces:
- Closeable,- AutoCloseable
 
 public class JarInputStream extends ZipInputStream TheJarInputStreamclass is used to read the contents of a JAR file from any input stream. It extends the classjava.util.zip.ZipInputStreamwith support for reading an optionalManifestentry. TheManifestcan be used to store meta-information about the JAR file and its entries.- Since:
- 1.2
- See Also:
- Manifest,- ZipInputStream
 
- 
- 
Field SummaryFields Modifier and Type Field Description static intCENATTstatic intCENATXstatic intCENCOMstatic intCENCRCstatic intCENDSKstatic intCENEXTstatic intCENFLGstatic intCENHDRstatic intCENHOWstatic intCENLENstatic intCENNAMstatic intCENOFFstatic longCENSIGstatic intCENSIZstatic intCENTIMstatic intCENVEMstatic intCENVERstatic intENDCOMstatic intENDHDRstatic intENDOFFstatic longENDSIGstatic intENDSIZstatic intENDSUBstatic intENDTOTstatic intEXTCRCstatic intEXTHDRstatic intEXTLENstatic longEXTSIGstatic intEXTSIZstatic intLOCCRCstatic intLOCEXTstatic intLOCFLGstatic intLOCHDRstatic intLOCHOWstatic intLOCLENstatic intLOCNAMstatic longLOCSIGstatic intLOCSIZstatic intLOCTIMstatic intLOCVER- 
Fields declared in class java.util.zip.InflaterInputStreambuf, inf, len
 - 
Fields declared in class java.io.FilterInputStreamin
 
- 
 - 
Constructor SummaryConstructors Constructor Description JarInputStream(InputStream in)Creates a newJarInputStreamand reads the optional manifest.JarInputStream(InputStream in, boolean verify)Creates a newJarInputStreamand reads the optional manifest.
 - 
Method SummaryAll Methods Instance Methods Concrete Methods Modifier and Type Method Description protected ZipEntrycreateZipEntry(String name)Creates a newJarEntry(ZipEntry) for the specified JAR file entry name.ManifestgetManifest()Returns theManifestfor this JAR file, ornullif none.ZipEntrygetNextEntry()Reads the next ZIP file entry and positions the stream at the beginning of the entry data.JarEntrygetNextJarEntry()Reads the next JAR file entry and positions the stream at the beginning of the entry data.intread(byte[] b, int off, int len)Reads from the current JAR file entry into an array of bytes.- 
Methods declared in class java.util.zip.ZipInputStreamavailable, close, closeEntry, skip
 - 
Methods declared in class java.util.zip.InflaterInputStreamfill, mark, markSupported, read, reset
 - 
Methods declared in class java.io.FilterInputStreamread
 - 
Methods declared in class java.io.InputStreamnullInputStream, readAllBytes, readNBytes, readNBytes, transferTo
 
- 
 
- 
- 
- 
Field Detail- 
LOCSIGpublic static final long LOCSIG - See Also:
- Constant Field Values
 
 - 
EXTSIGpublic static final long EXTSIG - See Also:
- Constant Field Values
 
 - 
CENSIGpublic static final long CENSIG - See Also:
- Constant Field Values
 
 - 
ENDSIGpublic static final long ENDSIG - See Also:
- Constant Field Values
 
 - 
LOCHDRpublic static final int LOCHDR - See Also:
- Constant Field Values
 
 - 
EXTHDRpublic static final int EXTHDR - See Also:
- Constant Field Values
 
 - 
CENHDRpublic static final int CENHDR - See Also:
- Constant Field Values
 
 - 
ENDHDRpublic static final int ENDHDR - See Also:
- Constant Field Values
 
 - 
LOCVERpublic static final int LOCVER - See Also:
- Constant Field Values
 
 - 
LOCFLGpublic static final int LOCFLG - See Also:
- Constant Field Values
 
 - 
LOCHOWpublic static final int LOCHOW - See Also:
- Constant Field Values
 
 - 
LOCTIMpublic static final int LOCTIM - See Also:
- Constant Field Values
 
 - 
LOCCRCpublic static final int LOCCRC - See Also:
- Constant Field Values
 
 - 
LOCSIZpublic static final int LOCSIZ - See Also:
- Constant Field Values
 
 - 
LOCLENpublic static final int LOCLEN - See Also:
- Constant Field Values
 
 - 
LOCNAMpublic static final int LOCNAM - See Also:
- Constant Field Values
 
 - 
LOCEXTpublic static final int LOCEXT - See Also:
- Constant Field Values
 
 - 
EXTCRCpublic static final int EXTCRC - See Also:
- Constant Field Values
 
 - 
EXTSIZpublic static final int EXTSIZ - See Also:
- Constant Field Values
 
 - 
EXTLENpublic static final int EXTLEN - See Also:
- Constant Field Values
 
 - 
CENVEMpublic static final int CENVEM - See Also:
- Constant Field Values
 
 - 
CENVERpublic static final int CENVER - See Also:
- Constant Field Values
 
 - 
CENFLGpublic static final int CENFLG - See Also:
- Constant Field Values
 
 - 
CENHOWpublic static final int CENHOW - See Also:
- Constant Field Values
 
 - 
CENTIMpublic static final int CENTIM - See Also:
- Constant Field Values
 
 - 
CENCRCpublic static final int CENCRC - See Also:
- Constant Field Values
 
 - 
CENSIZpublic static final int CENSIZ - See Also:
- Constant Field Values
 
 - 
CENLENpublic static final int CENLEN - See Also:
- Constant Field Values
 
 - 
CENNAMpublic static final int CENNAM - See Also:
- Constant Field Values
 
 - 
CENEXTpublic static final int CENEXT - See Also:
- Constant Field Values
 
 - 
CENCOMpublic static final int CENCOM - See Also:
- Constant Field Values
 
 - 
CENDSKpublic static final int CENDSK - See Also:
- Constant Field Values
 
 - 
CENATTpublic static final int CENATT - See Also:
- Constant Field Values
 
 - 
CENATXpublic static final int CENATX - See Also:
- Constant Field Values
 
 - 
CENOFFpublic static final int CENOFF - See Also:
- Constant Field Values
 
 - 
ENDSUBpublic static final int ENDSUB - See Also:
- Constant Field Values
 
 - 
ENDTOTpublic static final int ENDTOT - See Also:
- Constant Field Values
 
 - 
ENDSIZpublic static final int ENDSIZ - See Also:
- Constant Field Values
 
 - 
ENDOFFpublic static final int ENDOFF - See Also:
- Constant Field Values
 
 - 
ENDCOMpublic static final int ENDCOM - See Also:
- Constant Field Values
 
 
- 
 - 
Constructor Detail- 
JarInputStreampublic JarInputStream(InputStream in) throws IOException Creates a newJarInputStreamand reads the optional manifest. If a manifest is present, also attempts to verify the signatures if the JarInputStream is signed.- Parameters:
- in- the actual input stream
- Throws:
- IOException- if an I/O error has occurred
 
 - 
JarInputStreampublic JarInputStream(InputStream in, boolean verify) throws IOException Creates a newJarInputStreamand 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- the actual input stream
- verify- whether or not to verify the JarInputStream if it is signed.
- Throws:
- IOException- if an I/O error has occurred
 
 
- 
 - 
Method Detail- 
getManifestpublic Manifest getManifest() Returns theManifestfor this JAR file, ornullif none.- Returns:
- the Manifestfor this JAR file, ornullif none.
 
 - 
getNextEntrypublic ZipEntry getNextEntry() throws IOException 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.- Overrides:
- getNextEntryin class- ZipInputStream
- Returns:
- the next ZIP file entry, or null if there are no more entries
- Throws:
- ZipException- if a ZIP file error has occurred
- IOException- if an I/O error has occurred
- SecurityException- if any of the jar file entries are incorrectly signed.
 
 - 
getNextJarEntrypublic JarEntry getNextJarEntry() throws IOException 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:
- the next JAR file entry, or null if there are no more entries
- Throws:
- ZipException- if a ZIP file error has occurred
- IOException- if an I/O error has occurred
- SecurityException- if any of the jar file entries are incorrectly signed.
 
 - 
readpublic int read(byte[] b, int off, int len) throws IOExceptionReads from the current JAR file entry into an array of bytes. Iflenis not zero, the method blocks until some input is available; otherwise, no bytes are read and0is 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.- Overrides:
- readin class- ZipInputStream
- Parameters:
- b- the buffer into which the data is read
- off- the start offset in the destination array- b
- len- the maximum number of bytes to read
- Returns:
- the actual number of bytes read, or -1 if the end of the entry is reached
- Throws:
- NullPointerException- If- bis- null.
- IndexOutOfBoundsException- If- offis negative,- lenis negative, or- lenis greater than- b.length - off
- ZipException- if a ZIP file error has occurred
- IOException- if an I/O error has occurred
- SecurityException- if any of the jar file entries are incorrectly signed.
- See Also:
- FilterInputStream.in
 
 - 
createZipEntryprotected ZipEntry createZipEntry(String name) Creates a newJarEntry(ZipEntry) for the specified JAR file entry name. The manifest attributes of the specified JAR file entry name will be copied to the newJarEntry.- Overrides:
- createZipEntryin class- ZipInputStream
- Parameters:
- name- the name of the JAR/ZIP file entry
- Returns:
- the JarEntryobject just created
 
 
- 
 
-