java.util.zip

Class ZipInputStream

public class ZipInputStream extends InflaterInputStream implements 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.
Constructor Summary
ZipInputStream(InputStream in)
Creates a new Zip input stream, reading a zip archive.
Method Summary
intavailable()
voidclose()
Closes the zip file.
voidcloseEntry()
Closes the current zip entry and moves to the next one.
protected ZipEntrycreateZipEntry(String name)
Creates a new zip entry for the given name.
ZipEntrygetNextEntry()
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.

Constructor Detail

ZipInputStream

public ZipInputStream(InputStream in)
Creates a new Zip input stream, reading a zip archive.

Method Detail

available

public int available()

close

public void close()
Closes the zip file.

Throws: IOException if a i/o error occured.

closeEntry

public void closeEntry()
Closes the current zip entry and moves to the next one.

createZipEntry

protected ZipEntry createZipEntry(String name)
Creates a new zip entry for the given name. This is equivalent to new ZipEntry(name).

Parameters: name the name of the zip entry.

getNextEntry

public ZipEntry 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.

read

public int read()
Reads a byte from the current zip entry.

Returns: the byte or -1 on EOF.

Throws: IOException if a i/o error occured. ZipException if the deflated stream is corrupted.

read

public int read(byte[] b, int off, int len)
Reads a block of bytes from the current zip entry.

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.