Name

ZipInputStream

Synopsis

This class is a subclass of InflaterInputStream that reads the entries of a ZIP file in sequential order. Create a ZipInputStream by specifying the InputStream from which it is to read the contents of the ZIP file. Once the ZipInputStream is created, you can use getNextEntry( ) to begin reading data from the next entry in the ZIP file. This method must be called before read( ) is called to begin reading the first entry. getNextEntry( ) returns a ZipEntry object that describes the entry being read, or null when there are no more entries to be read from the ZIP file.

The read( ) methods of ZipInputStream read until the end of the current entry and then return -1, indicating that there is no more data to read. To continue with the next entry in the ZIP file, you must call getNextEntry( ) again. Similarly, the skip( ) method only skips bytes within the current entry. closeEntry( ) can be called to skip the remaining data in the current entry, but it is usually easier simply to call getNextEntry( ) to begin the next entry.

java.util.zip.ZipInputStream

Figure 16-146. java.util.zip.ZipInputStream

public class ZipInputStream extends InflaterInputStream implements ZipConstants {
// Public Constructors
     public ZipInputStream(java.io.InputStream in);  
// Public Instance Methods
     public void closeEntry( ) throws java.io.IOException;  
     public ZipEntry getNextEntry( ) throws java.io.IOException;  
// Public ...

Get Java in a Nutshell, 5th Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.