java.util.zip - ZipFile Class


Advertisements

Introduction

The java.util.zip.ZipFile class is used to read entries from a zip file.

Class declaration

Following is the declaration for java.util.zip.ZipFile class −

public class ZipFile
   extends Object
      implements Closeable

Fields

Following are the fields for java.util.zip.ZipFile class −

  • 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

  • static int OPEN_DELETE − Mode flag to open a zip file and mark it for deletion.

  • static int OPEN_READ − Mode flag to open a zip file for reading.

Constructors

Sr.No. Constructor & Description
1

ZipFile(File file)

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

2

ZipFile(File file, Charset charset)

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

3

ZipFile(File file, int mode)

Opens a new ZipFile to read from the specified File object in the specified mode.

4

ZipFile(File file, int mode, Charset charset)

Opens a new ZipFile to read from the specified File object in the specified mode.

5

ZipFile(String name)

Opens a zip file for reading.

6

ZipFile(String name, Charset charset)

Opens a zip file for reading.

Class methods

Sr.No. Method & Description
1 void close()

Closes the ZIP file.

2 Enumeration<? extends ZipEntry> entries()

Returns an enumeration of the ZIP file entries.

3 String getComment()

Returns the zip file comment, or null if none.

4 ZipEntry getEntry(String name)

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

5 InputStream getInputStream(ZipEntry entry)

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

6 String getName()

Returns the path name of the ZIP file.

7 int size()

Returns the number of entries in the ZIP file.

Methods inherited

This class inherits methods from the following classes −

  • Java.lang.Object
Print