ZipFile 

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 −

publicclassZipFileextendsObjectimplementsCloseable

Learn Java in-depth with real-world projects through our Java certification course. Enroll and become a certified expert to boost your career.

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
1ZipFile(File file)Opens a ZIP file for reading given the specified File object.
2ZipFile(File file, Charset charset)Opens a ZIP file for reading given the specified File object.
3ZipFile(File file, int mode)Opens a new ZipFile to read from the specified File object in the specified mode.
4ZipFile(File file, int mode, Charset charset)Opens a new ZipFile to read from the specified File object in the specified mode.
5ZipFile(String name)Opens a zip file for reading.
6ZipFile(String name, Charset charset)Opens a zip file for reading.

Class Methods

Sr.No.Method & Description
1void close()Closes the ZIP file.
2Enumeration<? extends ZipEntry> entries()Returns an enumeration of the ZIP file entries.
3String getComment()Returns the zip file comment, or null if none.
4ZipEntry getEntry(String name)Returns the zip file entry for the specified name, or null if not found.
5InputStream getInputStream(ZipEntry entry)Returns an input stream for reading the contents of the specified zip file entry.
6String getName()Returns the path name of the ZIP file.
7int size()Returns the number of entries in the ZIP file.

Methods Inherited

This class inherits methods from the following classes −

  • Java.lang.Object

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *