Class ZipInputStream
java.lang.Object
java.io.InputStream
java.io.FilterInputStream
net.sf.jazzlib.InflaterInputStream
net.sf.jazzlib.ZipInputStream
- All Implemented Interfaces:
Closeable, AutoCloseable, ZipConstants
This is a FilterInputStream that reads the files in an zip archive one after
another. It has a special method to get the zip entry of the next file. The
zip entry contains information about the file name size, compressed size,
CRC, etc.
It includes support for STORED and DEFLATED entries.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate intprivate CRC32private intprivate ZipEntryprivate booleanprivate intprivate intprivate intFields inherited from class InflaterInputStream
buf, inf, lenFields inherited from class FilterInputStream
inFields inherited from interface ZipConstants
CENATT, CENATX, CENCOM, CENCRC, CENDSK, CENEXT, CENFLG, CENHDR, CENHOW, CENLEN, CENNAM, CENOFF, CENSIG, CENSIZ, CENTIM, CENVEM, CENVER, ENDCOM, ENDDCD, ENDHDR, ENDNRD, ENDOFF, ENDSIG, ENDSIZ, ENDSUB, ENDTOT, EXTCRC, EXTHDR, EXTLEN, EXTSIG, EXTSIZ, LOCCRC, LOCEXT, LOCFLG, LOCHDR, LOCHOW, LOCLEN, LOCNAM, LOCSIG, LOCSIZ, LOCTIM, LOCVER -
Constructor Summary
ConstructorsConstructorDescriptionCreates a new Zip input stream, reading a zip archive. -
Method Summary
Modifier and TypeMethodDescriptionintReturns 0 once the end of the stream (EOF) has been reached.voidclose()Closes the zip file.voidCloses the current zip entry and moves to the next one.protected ZipEntrycreateZipEntry(String name) Creates a new zip entry for the given name.private voidfillBuf()Open the next entry from the zip archive, and return its description.intread()Reads a byte from the current zip entry.intread(byte[] b, int off, int len) Reads a block of bytes from the current zip entry.private intreadBuf(byte[] out, int offset, int length) private voidprivate voidreadFully(byte[] out) private final intprivate final intRead an int in little endian byte order.private final intRead an unsigned short in little endian byte order.Methods inherited from class InflaterInputStream
fill, skipMethods inherited from class FilterInputStream
mark, markSupported, read, resetMethods inherited from class InputStream
nullInputStream, readAllBytes, readNBytes, readNBytes, skipNBytes, transferTo
-
Field Details
-
crc
-
entry
-
csize
private int csize -
size
private int size -
method
private int method -
flags
private int flags -
avail
private int avail -
entryAtEOF
private boolean entryAtEOF
-
-
Constructor Details
-
ZipInputStream
Creates a new Zip input stream, reading a zip archive.
-
-
Method Details
-
fillBuf
- Throws:
IOException
-
readBuf
- Throws:
IOException
-
readFully
- Throws:
IOException
-
readLeByte
- Throws:
IOException
-
readLeShort
Read an unsigned short in little endian byte order.- Throws:
IOException
-
readLeInt
Read an int in little endian byte order.- Throws:
IOException
-
getNextEntry
Open the next entry from the zip archive, and return its description. If the previous entry wasn't closed, this method will close it.- Throws:
IOException
-
readDataDescr
- Throws:
IOException
-
closeEntry
Closes the current zip entry and moves to the next one.- Throws:
IOException
-
available
Description copied from class:InflaterInputStreamReturns 0 once the end of the stream (EOF) has been reached. Otherwise returns 1.- Overrides:
availablein classInflaterInputStream- Throws:
IOException
-
read
Reads a byte from the current zip entry.- Overrides:
readin classInflaterInputStream- Returns:
- the byte or -1 on EOF.
- Throws:
IOException- if a i/o error occured.ZipException- if the deflated stream is corrupted.
-
read
Reads a block of bytes from the current zip entry.- Overrides:
readin classInflaterInputStream- Parameters:
b- the array to read and decompress data intooff- the offset indicating where the data should be placedlen- the number of bytes to decompress- Returns:
- the number of bytes read (may be smaller, even before EOF), or -1 on EOF.
- Throws:
IOException- if a i/o error occured.ZipException- if the deflated stream is corrupted.
-
close
Closes the zip file.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Overrides:
closein classInflaterInputStream- Throws:
IOException- if a i/o error occured.
-
createZipEntry
-