Team LiB
Previous Section Next Section

ZipInputStreamjava.util.zip

Java 1.1closeable

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.

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 Methods Overriding InflaterInputStream
1.2  public int available( ) throws java.io.IOException;  
     public void close( ) throws java.io.IOException;  
     public int read(byte[ ] b, int off, int len) throws java.io.IOException;  
     public long skip(long n) throws java.io.IOException;  
// Protected Instance Methods
1.2  protected ZipEntry createZipEntry(String name);  
}

Subclasses

java.util.jar.JarInputStream

    Team LiB
    Previous Section Next Section