# ZipFile

public class **ZipFile** extends [Object](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html)  
implements [Closeable](https://developers.google.com/j2objc/javadoc/jre/reference/java/io/Closeable.html)

|---|---|---|
| Known Direct Subclasses [JarFile](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/jar/JarFile.html) |---|---| | [JarFile](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/jar/JarFile.html) | The `JarFile` class is used to read the contents of a jar file from any file that can be opened with `java.io.RandomAccessFile`. | |||

This class is used to read entries from a zip file.

Unless otherwise noted, passing a null argument to a constructor
or method in this class will cause a `https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/NullPointerException.html` to be
thrown.

### Constant Summary

|---|---|---|
| int | [CENATT](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/zip/ZipFile.html#CENATT) |   |
| int | [CENATX](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/zip/ZipFile.html#CENATX) |   |
| int | [CENCOM](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/zip/ZipFile.html#CENCOM) |   |
| int | [CENCRC](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/zip/ZipFile.html#CENCRC) |   |
| int | [CENDSK](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/zip/ZipFile.html#CENDSK) |   |
| int | [CENEXT](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/zip/ZipFile.html#CENEXT) |   |
| int | [CENFLG](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/zip/ZipFile.html#CENFLG) |   |
| int | [CENHDR](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/zip/ZipFile.html#CENHDR) |   |
| int | [CENHOW](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/zip/ZipFile.html#CENHOW) |   |
| int | [CENLEN](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/zip/ZipFile.html#CENLEN) |   |
| int | [CENNAM](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/zip/ZipFile.html#CENNAM) |   |
| int | [CENOFF](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/zip/ZipFile.html#CENOFF) |   |
| long | [CENSIG](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/zip/ZipFile.html#CENSIG) |   |
| int | [CENSIZ](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/zip/ZipFile.html#CENSIZ) |   |
| int | [CENTIM](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/zip/ZipFile.html#CENTIM) |   |
| int | [CENVEM](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/zip/ZipFile.html#CENVEM) |   |
| int | [CENVER](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/zip/ZipFile.html#CENVER) |   |
| int | [ENDCOM](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/zip/ZipFile.html#ENDCOM) |   |
| int | [ENDHDR](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/zip/ZipFile.html#ENDHDR) |   |
| int | [ENDOFF](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/zip/ZipFile.html#ENDOFF) |   |
| long | [ENDSIG](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/zip/ZipFile.html#ENDSIG) |   |
| int | [ENDSIZ](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/zip/ZipFile.html#ENDSIZ) |   |
| int | [ENDSUB](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/zip/ZipFile.html#ENDSUB) |   |
| int | [ENDTOT](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/zip/ZipFile.html#ENDTOT) |   |
| int | [EXTCRC](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/zip/ZipFile.html#EXTCRC) |   |
| int | [EXTHDR](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/zip/ZipFile.html#EXTHDR) |   |
| int | [EXTLEN](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/zip/ZipFile.html#EXTLEN) |   |
| long | [EXTSIG](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/zip/ZipFile.html#EXTSIG) |   |
| int | [EXTSIZ](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/zip/ZipFile.html#EXTSIZ) |   |
| int | [LOCCRC](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/zip/ZipFile.html#LOCCRC) |   |
| int | [LOCEXT](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/zip/ZipFile.html#LOCEXT) |   |
| int | [LOCFLG](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/zip/ZipFile.html#LOCFLG) |   |
| int | [LOCHDR](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/zip/ZipFile.html#LOCHDR) |   |
| int | [LOCHOW](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/zip/ZipFile.html#LOCHOW) |   |
| int | [LOCLEN](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/zip/ZipFile.html#LOCLEN) |   |
| int | [LOCNAM](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/zip/ZipFile.html#LOCNAM) |   |
| long | [LOCSIG](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/zip/ZipFile.html#LOCSIG) |   |
| int | [LOCSIZ](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/zip/ZipFile.html#LOCSIZ) |   |
| int | [LOCTIM](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/zip/ZipFile.html#LOCTIM) |   |
| int | [LOCVER](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/zip/ZipFile.html#LOCVER) |   |
| int | [OPEN_DELETE](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/zip/ZipFile.html#OPEN_DELETE) | Mode flag to open a zip file and mark it for deletion. |
| int | [OPEN_READ](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/zip/ZipFile.html#OPEN_READ) | Mode flag to open a zip file for reading. |

### Public Constructor Summary

|---|---|
|   | [ZipFile](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/zip/ZipFile.html#ZipFile(java.lang.String))([String](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/String.html) name) Opens a zip file for reading. |
|   | [ZipFile](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/zip/ZipFile.html#ZipFile(java.io.File,%20int))([File](https://developers.google.com/j2objc/javadoc/jre/reference/java/io/File.html) file, int mode) Opens a new `ZipFile` to read from the specified `File` object in the specified mode. |
|   | [ZipFile](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/zip/ZipFile.html#ZipFile(java.io.File))([File](https://developers.google.com/j2objc/javadoc/jre/reference/java/io/File.html) file) Opens a ZIP file for reading given the specified File object. |
|   | [ZipFile](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/zip/ZipFile.html#ZipFile(java.io.File,%20int,%20java.nio.charset.Charset))([File](https://developers.google.com/j2objc/javadoc/jre/reference/java/io/File.html) file, int mode, [Charset](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/charset/Charset.html) charset) Opens a new `ZipFile` to read from the specified `File` object in the specified mode. |
|   | [ZipFile](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/zip/ZipFile.html#ZipFile(java.lang.String,%20java.nio.charset.Charset))([String](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/String.html) name, [Charset](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/charset/Charset.html) charset) Opens a zip file for reading. |
|   | [ZipFile](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/zip/ZipFile.html#ZipFile(java.io.File,%20java.nio.charset.Charset))([File](https://developers.google.com/j2objc/javadoc/jre/reference/java/io/File.html) file, [Charset](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/charset/Charset.html) charset) Opens a ZIP file for reading given the specified File object. |

### Public Method Summary

|---|---|
| void | [close](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/zip/ZipFile.html#close())() Closes the ZIP file. |
| [Enumeration](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Enumeration.html)\<? extends [ZipEntry](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/zip/ZipEntry.html)\> | [entries](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/zip/ZipFile.html#entries())() Returns an enumeration of the ZIP file entries. |
| [String](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/String.html) | [getComment](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/zip/ZipFile.html#getComment())() Returns the zip file comment, or null if none. |
| [ZipEntry](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/zip/ZipEntry.html) | [getEntry](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/zip/ZipFile.html#getEntry(java.lang.String))([String](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/String.html) name) Returns the zip file entry for the specified name, or null if not found. |
| [InputStream](https://developers.google.com/j2objc/javadoc/jre/reference/java/io/InputStream.html) | [getInputStream](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/zip/ZipFile.html#getInputStream(java.util.zip.ZipEntry))([ZipEntry](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/zip/ZipEntry.html) entry) Returns an input stream for reading the contents of the specified zip file entry. |
| [String](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/String.html) | [getName](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/zip/ZipFile.html#getName())() Returns the path name of the ZIP file. |
| int | [size](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/zip/ZipFile.html#size())() Returns the number of entries in the ZIP file. |
| [Stream](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/stream/Stream.html)\<? extends [ZipEntry](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/zip/ZipEntry.html)\> | [stream](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/zip/ZipFile.html#stream())() Return an ordered `Stream` over the ZIP file entries. |

### Protected Method Summary

|---|---|
| void | [finalize](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/zip/ZipFile.html#finalize())() Ensures that the system resources held by this ZipFile object are released when there are no more references to it. |

### Inherited Method Summary

From class [java.lang.Object](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html)

|---|---|
| [Object](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html) | [clone](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#clone())() Creates and returns a copy of this `Object`. |
| boolean | [equals](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#equals(java.lang.Object))([Object](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html) obj) Compares this instance with the specified object and indicates if they are equal. |
| void | [finalize](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#finalize())() Invoked when the garbage collector has detected that this instance is no longer reachable. |
| final [Class](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Class.html)\<?\> | [getClass](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#getClass())() Returns the unique instance of `https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Class.html` that represents this object's class. |
| int | [hashCode](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#hashCode())() Returns an integer hash code for this object. |
| final void | [notify](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#notify())() Causes a thread which is waiting on this object's monitor (by means of calling one of the `wait()` methods) to be woken up. |
| final void | [notifyAll](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#notifyAll())() Causes all threads which are waiting on this object's monitor (by means of calling one of the `wait()` methods) to be woken up. |
| [String](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/String.html) | [toString](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#toString())() Returns a string containing a concise, human-readable description of this object. |
| final void | [wait](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#wait(long,%20int))(long timeout, int nanos) Causes the calling thread to wait until another thread calls the `notify()` or `notifyAll()` method of this object or until the specified timeout expires. |
| final void | [wait](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#wait(long))(long timeout) Causes the calling thread to wait until another thread calls the `notify()` or `notifyAll()` method of this object or until the specified timeout expires. |
| final void | [wait](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#wait())() Causes the calling thread to wait until another thread calls the `notify()` or `notifyAll()` method of this object. |

From interface [java.io.Closeable](https://developers.google.com/j2objc/javadoc/jre/reference/java/io/Closeable.html)

|---|---|
| abstract void | [close](https://developers.google.com/j2objc/javadoc/jre/reference/java/io/Closeable.html#close())() Closes this stream and releases any system resources associated with it. |

From interface [java.lang.AutoCloseable](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/AutoCloseable.html)

|---|---|
| abstract void | [close](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/AutoCloseable.html#close())() Closes this resource, relinquishing any underlying resources. |

## Constants

#### public static final int
**CENATT**

<br />

Constant Value: 36

#### public static final int
**CENATX**

<br />

Constant Value: 38

#### public static final int
**CENCOM**

<br />

Constant Value: 32

#### public static final int
**CENCRC**

<br />

Constant Value: 16

#### public static final int
**CENDSK**

<br />

Constant Value: 34

#### public static final int
**CENEXT**

<br />

Constant Value: 30

#### public static final int
**CENFLG**

<br />

Constant Value: 8

#### public static final int
**CENHDR**

<br />

Constant Value: 46

#### public static final int
**CENHOW**

<br />

Constant Value: 10

#### public static final int
**CENLEN**

<br />

Constant Value: 24

#### public static final int
**CENNAM**

<br />

Constant Value: 28

#### public static final int
**CENOFF**

<br />

Constant Value: 42

#### public static final long
**CENSIG**

<br />

Constant Value: 33639248

#### public static final int
**CENSIZ**

<br />

Constant Value: 20

#### public static final int
**CENTIM**

<br />

Constant Value: 12

#### public static final int
**CENVEM**

<br />

Constant Value: 4

#### public static final int
**CENVER**

<br />

Constant Value: 6

#### public static final int
**ENDCOM**

<br />

Constant Value: 20

#### public static final int
**ENDHDR**

<br />

Constant Value: 22

#### public static final int
**ENDOFF**

<br />

Constant Value: 16

#### public static final long
**ENDSIG**

<br />

Constant Value: 101010256

#### public static final int
**ENDSIZ**

<br />

Constant Value: 12

#### public static final int
**ENDSUB**

<br />

Constant Value: 8

#### public static final int
**ENDTOT**

<br />

Constant Value: 10

#### public static final int
**EXTCRC**

<br />

Constant Value: 4

#### public static final int
**EXTHDR**

<br />

Constant Value: 16

#### public static final int
**EXTLEN**

<br />

Constant Value: 12

#### public static final long
**EXTSIG**

<br />

Constant Value: 134695760

#### public static final int
**EXTSIZ**

<br />

Constant Value: 8

#### public static final int
**LOCCRC**

<br />

Constant Value: 14

#### public static final int
**LOCEXT**

<br />

Constant Value: 28

#### public static final int
**LOCFLG**

<br />

Constant Value: 6

#### public static final int
**LOCHDR**

<br />

Constant Value: 30

#### public static final int
**LOCHOW**

<br />

Constant Value: 8

#### public static final int
**LOCLEN**

<br />

Constant Value: 22

#### public static final int
**LOCNAM**

<br />

Constant Value: 26

#### public static final long
**LOCSIG**

<br />

Constant Value: 67324752

#### public static final int
**LOCSIZ**

<br />

Constant Value: 18

#### public static final int
**LOCTIM**

<br />

Constant Value: 10

#### public static final int
**LOCVER**

<br />

Constant Value: 4

#### public static final int
**OPEN_DELETE**

Mode flag to open a zip file and mark it for deletion. The file will be
deleted some time between the moment that it is opened and the moment
that it is closed, but its contents will remain accessible via the
ZipFile object until either the close method is invoked or the
virtual machine exits.
Constant Value: 4

#### public static final int
**OPEN_READ**

Mode flag to open a zip file for reading.
Constant Value: 1

## Public Constructors

#### public
**ZipFile**
([String](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/String.html) name)

Opens a zip file for reading.

First, if there is a security manager, its `checkRead`
method is called with the `name` argument as its argument
to ensure the read is allowed.

The UTF-8 `https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/charset/Charset.html` is used to
decode the entry names and comments.

##### Parameters

| name | the name of the zip file |
|---|---|

##### Throws

| [ZipException](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/zip/ZipException.html) | if a ZIP format error has occurred |
| [IOException](https://developers.google.com/j2objc/javadoc/jre/reference/java/io/IOException.html) | if an I/O error has occurred |
| [SecurityException](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/SecurityException.html) | if a security manager exists and its `checkRead` method doesn't allow read access to the file. |
|---|---|

##### See Also

- `https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/SecurityManager.html#checkRead(java.lang.String)`

#### public
**ZipFile**
([File](https://developers.google.com/j2objc/javadoc/jre/reference/java/io/File.html) file, int mode)

Opens a new `ZipFile` to read from the specified
`File` object in the specified mode. The mode argument
must be either OPEN_READ or OPEN_READ \| OPEN_DELETE.

First, if there is a security manager, its `checkRead`
method is called with the `name` argument as its argument to
ensure the read is allowed.

The UTF-8 `https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/charset/Charset.html` is used to
decode the entry names and comments

##### Parameters

| file | the ZIP file to be opened for reading |
| mode | the mode in which the file is to be opened |
|---|---|

##### Throws

| [ZipException](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/zip/ZipException.html) | if a ZIP format error has occurred |
| [IOException](https://developers.google.com/j2objc/javadoc/jre/reference/java/io/IOException.html) | if an I/O error has occurred |
| [SecurityException](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/SecurityException.html) | if a security manager exists and its `checkRead` method doesn't allow read access to the file, or its `checkDelete` method doesn't allow deleting the file when the OPEN_DELETE flag is set. |
| [IllegalArgumentException](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/IllegalArgumentException.html) | if the mode argument is invalid |
|---|---|

##### See Also

- `https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/SecurityManager.html#checkRead(java.lang.String)`

#### public
**ZipFile**
([File](https://developers.google.com/j2objc/javadoc/jre/reference/java/io/File.html) file)

Opens a ZIP file for reading given the specified File object.

The UTF-8 `https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/charset/Charset.html` is used to
decode the entry names and comments.

##### Parameters

| file | the ZIP file to be opened for reading |
|---|---|

##### Throws

| [ZipException](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/zip/ZipException.html) | if a ZIP format error has occurred |
| [IOException](https://developers.google.com/j2objc/javadoc/jre/reference/java/io/IOException.html) | if an I/O error has occurred |
|---|---|

#### public
**ZipFile**
([File](https://developers.google.com/j2objc/javadoc/jre/reference/java/io/File.html) file, int mode, [Charset](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/charset/Charset.html) charset)

Opens a new `ZipFile` to read from the specified
`File` object in the specified mode. The mode argument
must be either OPEN_READ or OPEN_READ \| OPEN_DELETE.

First, if there is a security manager, its `checkRead`
method is called with the `name` argument as its argument to
ensure the read is allowed.

##### Parameters

| file | the ZIP file to be opened for reading |
| mode | the mode in which the file is to be opened |
| charset | the {@linkplain java.nio.charset.Charset charset} to be used to decode the ZIP entry name and comment that are not encoded by using UTF-8 encoding (indicated by entry's general purpose flag). |
|---|---|

##### Throws

| [ZipException](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/zip/ZipException.html) | if a ZIP format error has occurred |
| [IOException](https://developers.google.com/j2objc/javadoc/jre/reference/java/io/IOException.html) | if an I/O error has occurred |
| [SecurityException](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/SecurityException.html) | if a security manager exists and its `checkRead` method doesn't allow read access to the file,or its `checkDelete` method doesn't allow deleting the file when the OPEN_DELETE flag is set |
| [IllegalArgumentException](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/IllegalArgumentException.html) | if the mode argument is invalid |
|---|---|

##### See Also

- `https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/SecurityManager.html#checkRead(java.lang.String)`

#### public
**ZipFile**
([String](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/String.html) name, [Charset](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/charset/Charset.html) charset)

Opens a zip file for reading.

First, if there is a security manager, its `checkRead`
method is called with the `name` argument as its argument
to ensure the read is allowed.

##### Parameters

| name | the name of the zip file |
| charset | the {@linkplain java.nio.charset.Charset charset} to be used to decode the ZIP entry name and comment that are not encoded by using UTF-8 encoding (indicated by entry's general purpose flag). |
|---|---|

##### Throws

| [ZipException](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/zip/ZipException.html) | if a ZIP format error has occurred |
| [IOException](https://developers.google.com/j2objc/javadoc/jre/reference/java/io/IOException.html) | if an I/O error has occurred |
| [SecurityException](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/SecurityException.html) | if a security manager exists and its `checkRead` method doesn't allow read access to the file |
|---|---|

##### See Also

- `https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/SecurityManager.html#checkRead(java.lang.String)`

#### public
**ZipFile**
([File](https://developers.google.com/j2objc/javadoc/jre/reference/java/io/File.html) file, [Charset](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/charset/Charset.html) charset)

Opens a ZIP file for reading given the specified File object.

##### Parameters

| file | the ZIP file to be opened for reading |
| charset | The {@linkplain java.nio.charset.Charset charset} to be used to decode the ZIP entry name and comment (ignored if the [language encoding bit](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/zip/package-summary#lang_encoding) of the ZIP entry's general purpose bit flag is set). |
|---|---|

##### Throws

| [ZipException](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/zip/ZipException.html) | if a ZIP format error has occurred |
| [IOException](https://developers.google.com/j2objc/javadoc/jre/reference/java/io/IOException.html) | if an I/O error has occurred |
|---|---|

## Public Methods

#### public void
**close**
()

Closes the ZIP file.

Closing this ZIP file will close all of the input streams
previously returned by invocations of the `https://developers.google.com/j2objc/javadoc/jre/reference/java/util/zip/ZipFile.html#getInputStream(java.util.zip.ZipEntry)` method.

##### Throws

| [IOException](https://developers.google.com/j2objc/javadoc/jre/reference/java/io/IOException.html) | if an I/O error has occurred |
|---|---|

#### public [Enumeration](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Enumeration.html)\<? extends [ZipEntry](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/zip/ZipEntry.html)\>
**entries**
()

Returns an enumeration of the ZIP file entries.

##### Returns

- an enumeration of the ZIP file entries

##### Throws

| [IllegalStateException](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/IllegalStateException.html) | if the zip file has been closed |
|---|---|

#### public [String](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/String.html)
**getComment**
()

Returns the zip file comment, or null if none.

##### Returns

- the comment string for the zip file, or null if none

##### Throws

| [IllegalStateException](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/IllegalStateException.html) | if the zip file has been closed Since 1.7 |
|---|---|

#### public [ZipEntry](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/zip/ZipEntry.html)
**getEntry**
([String](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/String.html) name)

Returns the zip file entry for the specified name, or null
if not found.

##### Parameters

| name | the name of the entry |
|---|---|

##### Returns

- the zip file entry, or null if not found

##### Throws

| [IllegalStateException](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/IllegalStateException.html) | if the zip file has been closed |
|---|---|

#### public [InputStream](https://developers.google.com/j2objc/javadoc/jre/reference/java/io/InputStream.html)
**getInputStream**
([ZipEntry](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/zip/ZipEntry.html) entry)

Returns an input stream for reading the contents of the specified
zip file entry.

Closing this ZIP file will, in turn, close all input
streams that have been returned by invocations of this method.

##### Parameters

| entry | the zip file entry |
|---|---|

##### Returns

- the input stream for reading the contents of the specified zip file entry.

##### Throws

| [ZipException](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/zip/ZipException.html) | if a ZIP format error has occurred |
| [IOException](https://developers.google.com/j2objc/javadoc/jre/reference/java/io/IOException.html) | if an I/O error has occurred |
| [IllegalStateException](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/IllegalStateException.html) | if the zip file has been closed |
|---|---|

#### public [String](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/String.html)
**getName**
()

Returns the path name of the ZIP file.

##### Returns

- the path name of the ZIP file

#### public int
**size**
()

Returns the number of entries in the ZIP file.

##### Returns

- the number of entries in the ZIP file

##### Throws

| [IllegalStateException](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/IllegalStateException.html) | if the zip file has been closed |
|---|---|

#### public [Stream](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/stream/Stream.html)\<? extends [ZipEntry](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/zip/ZipEntry.html)\>
**stream**
()

Return an ordered `Stream` over the ZIP file entries.
Entries appear in the `Stream` in the order they appear in
the central directory of the ZIP file.

##### Returns

- an ordered `Stream` of entries in this ZIP file

##### Throws

| [IllegalStateException](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/IllegalStateException.html) | if the zip file has been closed |
|---|---|

## Protected Methods

#### protected void
**finalize**
()

Ensures that the system resources held by this ZipFile object are
released when there are no more references to it.


Since the time when GC would invoke this method is undetermined,
it is strongly recommended that applications invoke the `close`
method as soon they have finished accessing this `ZipFile`.
This will prevent holding up system resources for an undetermined
length of time.

##### Throws

| [IOException](https://developers.google.com/j2objc/javadoc/jre/reference/java/io/IOException.html) | if an I/O error has occurred |
|---|---|

##### See Also

- `https://developers.google.com/j2objc/javadoc/jre/reference/java/util/zip/ZipFile.html#close()`