- java.lang.Object
- 
- java.io.InputStream
- 
- java.io.FilterInputStream
- 
- java.util.zip.InflaterInputStream
- 
- java.util.zip.ZipInputStream
 
 
 
 
- 
- All Implemented Interfaces:
- Closeable,- AutoCloseable
 - Direct Known Subclasses:
- JarInputStream
 
 public class ZipInputStream extends InflaterInputStream This class implements an input stream filter for reading files in the ZIP file format. Includes support for both compressed and uncompressed entries.- Since:
- 1.1
 
- 
- 
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 ZipInputStream(InputStream in)Creates a new ZIP input stream.ZipInputStream(InputStream in, Charset charset)Creates a new ZIP input stream.
 - 
Method SummaryAll Methods Instance Methods Concrete Methods Modifier and Type Method Description intavailable()Returns 0 after EOF has reached for the current entry data, otherwise always return 1.voidclose()Closes this input stream and releases any system resources associated with the stream.voidcloseEntry()Closes the current ZIP entry and positions the stream for reading the next entry.protected ZipEntrycreateZipEntry(String name)Creates a newZipEntryobject for the specified entry name.ZipEntrygetNextEntry()Reads the next ZIP file entry and positions the stream at the beginning of the entry data.intread(byte[] b, int off, int len)Reads from the current ZIP entry into an array of bytes.longskip(long n)Skips specified number of bytes in the current ZIP entry.- 
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- 
ZipInputStreampublic ZipInputStream(InputStream in) Creates a new ZIP input stream.The UTF-8 charsetis used to decode the entry names.- Parameters:
- in- the actual input stream
 
 - 
ZipInputStreampublic ZipInputStream(InputStream in, Charset charset) Creates a new ZIP input stream.- Parameters:
- in- the actual input stream
- charset- The charset to be used to decode the ZIP entry name (ignored if the language encoding bit of the ZIP entry's general purpose bit flag is set).
- Since:
- 1.7
 
 
- 
 - 
Method Detail- 
getNextEntrypublic ZipEntry getNextEntry() throws IOException Reads the next ZIP file entry and positions the stream at the beginning of the entry data.- 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
 
 - 
closeEntrypublic void closeEntry() throws IOExceptionCloses the current ZIP entry and positions the stream for reading the next entry.- Throws:
- ZipException- if a ZIP file error has occurred
- IOException- if an I/O error has occurred
 
 - 
availablepublic int available() throws IOExceptionReturns 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. - Overrides:
- availablein class- InflaterInputStream
- Returns:
- 1 before EOF and 0 after EOF has reached for current entry.
- Throws:
- IOException- if an I/O error occurs.
 
 - 
readpublic int read(byte[] b, int off, int len) throws IOExceptionReads from the current ZIP entry into an array of bytes. Iflenis not zero, the method blocks until some input is available; otherwise, no bytes are read and0is returned.- Overrides:
- readin class- InflaterInputStream
- 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 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
- See Also:
- FilterInputStream.in
 
 - 
skippublic long skip(long n) throws IOExceptionSkips specified number of bytes in the current ZIP entry.- Overrides:
- skipin class- InflaterInputStream
- Parameters:
- n- the number of bytes to skip
- Returns:
- the actual number of bytes skipped
- Throws:
- ZipException- if a ZIP file error has occurred
- IOException- if an I/O error has occurred
- IllegalArgumentException- if- n < 0
 
 - 
closepublic void close() throws IOExceptionCloses this input stream and releases any system resources associated with the stream.- Specified by:
- closein interface- AutoCloseable
- Specified by:
- closein interface- Closeable
- Overrides:
- closein class- InflaterInputStream
- Throws:
- IOException- if an I/O error has occurred
- See Also:
- FilterInputStream.in
 
 
- 
 
-