net.sf.zipme
Class ZipInputStream

java.lang.Object
  extended byjava.io.InputStream
      extended bynet.sf.zipme.InflaterInputStream
          extended bynet.sf.zipme.ZipInputStream
All Implemented Interfaces:
net.sf.zipme.ZipConstants

public class ZipInputStream
extends InflaterInputStream
implements net.sf.zipme.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
static int CENATT
           
static int CENATX
           
static int CENCOM
           
static int CENCRC
           
static int CENDSK
           
static int CENEXT
           
static int CENFLG
           
static int CENHDR
           
static int CENHOW
           
static int CENLEN
           
static int CENNAM
           
static int CENOFF
           
static long CENSIG
           
static int CENSIZ
           
static int CENTIM
           
static int CENVEM
           
static int CENVER
           
static int ENDCOM
           
static int ENDHDR
           
static int ENDOFF
           
static long ENDSIG
           
static int ENDSIZ
           
static int ENDSUB
           
static int ENDTOT
           
static int EXTCRC
           
static int EXTHDR
           
static int EXTLEN
           
static long EXTSIG
           
static int EXTSIZ
           
static int LOCCRC
           
static int LOCEXT
           
static int LOCFLG
           
static int LOCHDR
           
static int LOCHOW
           
static int LOCLEN
           
static int LOCNAM
           
static long LOCSIG
           
static int LOCSIZ
           
static int LOCTIM
           
static int LOCVER
           
 
Fields inherited from class net.sf.zipme.InflaterInputStream
buf, in, inf, len
 
Constructor Summary
ZipInputStream(java.io.InputStream in)
          Creates a new Zip input stream, reading a zip archive.
 
Method Summary
 int available()
          Returns 0 once the end of the stream (EOF) has been reached.
 void close()
          Closes the zip file.
 void closeEntry()
          Closes the current zip entry and moves to the next one.
protected  ZipEntry createZipEntry(java.lang.String name)
          Creates a new zip entry for the given name.
 ZipEntry getNextEntry()
          Open the next entry from the zip archive, and return its description.
 int read()
          Reads a byte from the current zip entry.
 int read(byte[] b, int off, int len)
          Reads a block of bytes from the current zip entry.
 
Methods inherited from class net.sf.zipme.InflaterInputStream
fill, mark, markSupported, read, reset, skip
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LOCHDR

public static final int LOCHDR
See Also:
Constant Field Values

LOCSIG

public static final long LOCSIG
See Also:
Constant Field Values

LOCVER

public static final int LOCVER
See Also:
Constant Field Values

LOCFLG

public static final int LOCFLG
See Also:
Constant Field Values

LOCHOW

public static final int LOCHOW
See Also:
Constant Field Values

LOCTIM

public static final int LOCTIM
See Also:
Constant Field Values

LOCCRC

public static final int LOCCRC
See Also:
Constant Field Values

LOCSIZ

public static final int LOCSIZ
See Also:
Constant Field Values

LOCLEN

public static final int LOCLEN
See Also:
Constant Field Values

LOCNAM

public static final int LOCNAM
See Also:
Constant Field Values

LOCEXT

public static final int LOCEXT
See Also:
Constant Field Values

EXTSIG

public static final long EXTSIG
See Also:
Constant Field Values

EXTHDR

public static final int EXTHDR
See Also:
Constant Field Values

EXTCRC

public static final int EXTCRC
See Also:
Constant Field Values

EXTSIZ

public static final int EXTSIZ
See Also:
Constant Field Values

EXTLEN

public static final int EXTLEN
See Also:
Constant Field Values

CENSIG

public static final long CENSIG
See Also:
Constant Field Values

CENHDR

public static final int CENHDR
See Also:
Constant Field Values

CENVEM

public static final int CENVEM
See Also:
Constant Field Values

CENVER

public static final int CENVER
See Also:
Constant Field Values

CENFLG

public static final int CENFLG
See Also:
Constant Field Values

CENHOW

public static final int CENHOW
See Also:
Constant Field Values

CENTIM

public static final int CENTIM
See Also:
Constant Field Values

CENCRC

public static final int CENCRC
See Also:
Constant Field Values

CENSIZ

public static final int CENSIZ
See Also:
Constant Field Values

CENLEN

public static final int CENLEN
See Also:
Constant Field Values

CENNAM

public static final int CENNAM
See Also:
Constant Field Values

CENEXT

public static final int CENEXT
See Also:
Constant Field Values

CENCOM

public static final int CENCOM
See Also:
Constant Field Values

CENDSK

public static final int CENDSK
See Also:
Constant Field Values

CENATT

public static final int CENATT
See Also:
Constant Field Values

CENATX

public static final int CENATX
See Also:
Constant Field Values

CENOFF

public static final int CENOFF
See Also:
Constant Field Values

ENDSIG

public static final long ENDSIG
See Also:
Constant Field Values

ENDHDR

public static final int ENDHDR
See Also:
Constant Field Values

ENDSUB

public static final int ENDSUB
See Also:
Constant Field Values

ENDTOT

public static final int ENDTOT
See Also:
Constant Field Values

ENDSIZ

public static final int ENDSIZ
See Also:
Constant Field Values

ENDOFF

public static final int ENDOFF
See Also:
Constant Field Values

ENDCOM

public static final int ENDCOM
See Also:
Constant Field Values
Constructor Detail

ZipInputStream

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

Method Detail

getNextEntry

public ZipEntry getNextEntry()
                      throws java.io.IOException
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:
java.io.IOException

closeEntry

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

Throws:
java.io.IOException

available

public int available()
              throws java.io.IOException
Description copied from class: InflaterInputStream
Returns 0 once the end of the stream (EOF) has been reached. Otherwise returns 1.

Overrides:
available in class InflaterInputStream
Throws:
java.io.IOException

read

public int read()
         throws java.io.IOException
Reads a byte from the current zip entry.

Overrides:
read in class InflaterInputStream
Returns:
the byte or -1 on EOF.
Throws:
java.io.IOException - if a i/o error occured.
ZipException - if the deflated stream is corrupted.

read

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

Overrides:
read in class InflaterInputStream
Parameters:
b - the array to read and decompress data into
off - the offset indicating where the data should be placed
len - the number of bytes to decompress
Returns:
the number of bytes read (may be smaller, even before EOF), or -1 on EOF.
Throws:
java.io.IOException - if a i/o error occured.
ZipException - if the deflated stream is corrupted.

close

public void close()
           throws java.io.IOException
Closes the zip file.

Overrides:
close in class InflaterInputStream
Throws:
java.io.IOException - if a i/o error occured.

createZipEntry

protected ZipEntry createZipEntry(java.lang.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.