Index (Frames) | Index (No Frames) | Package | Package Tree | Tree
java.util.zip

Class ZipFile

java.lang.Object
|
+--java.util.zip.ZipFile

All Implemented Interfaces:

java.util.zip.ZipConstants


public class ZipFile

extends Object

implements java.util.zip.ZipConstants

This class represents a Zip archive. You can ask for the contained entries, or get an input stream for a file entry. The entry is automatically decompressed. This class is thread safe: You can open input streams for arbitrary entries in different threads.

Authors:

Field Summary

static intOPEN_DELETE

Mode flag to delete a zip file after reading.
static intOPEN_READ

Mode flag to open a zip file for reading.

Constructor Summary

ZipFile(java.lang.String name)

Opens a Zip file with the given name for reading.
ZipFile(java.io.File file)

Opens a Zip file reading the given File.
ZipFile(java.io.File file, int mode)

Opens a Zip file reading the given File in the given mode.

Method Summary

voidclose()

Closes the ZipFile.
java.util.Enumerationentries()

Returns an enumeration of all Zip entries in this Zip file.
java.util.zip.ZipEntrygetEntry(java.lang.String name)

Searches for a zip entry in this archive with the given name.
java.io.InputStreamgetInputStream(java.util.zip.ZipEntry entry)

Creates an input stream reading the given zip entry as uncompressed data.
java.lang.StringgetName()

Returns the name of this zip file.
intsize()

Returns the number of entries in this zip file.

Field Details

OPEN_DELETE

public static final int OPEN_DELETE

Mode flag to delete a zip file after reading.


OPEN_READ

public static final int OPEN_READ

Mode flag to open a zip file for reading.


Constructor Details

ZipFile

public ZipFile(java.io.File file)

Opens a Zip file reading the given File.

Parameters:

Throws:


ZipFile

public ZipFile(java.io.File file, int mode)

Opens a Zip file reading the given File in the given mode. If the OPEN_DELETE mode is specified, the zip file will be deleted at some time moment after it is opened. It will be deleted before the zip file is closed or the Virtual Machine exits. The contents of the zip file will be accessible until it is closed. The OPEN_DELETE mode is currently unimplemented in this library

Since:Parameters:

Throws:


ZipFile

public ZipFile(java.lang.String name)

Opens a Zip file with the given name for reading.

Parameters:

Throws:


Method Details

close

public void close()

Closes the ZipFile. This also closes all input streams given by this class. After this is called, no further method should be called.

Throws:


entries

public Enumeration entries()

Returns an enumeration of all Zip entries in this Zip file.


getEntry

public ZipEntry getEntry(java.lang.String name)

Searches for a zip entry in this archive with the given name.

Parameters:

Returns:


getInputStream

public InputStream getInputStream(java.util.zip.ZipEntry entry)

Creates an input stream reading the given zip entry as uncompressed data. Normally zip entry should be an entry returned by getEntry() or entries().

Parameters:

Returns:

Throws:


getName

public String getName()

Returns the name of this zip file.


size

public int size()

Returns the number of entries in this zip file.