Javazip 简明教程

java.util.zip - ZipFile Class

Introduction

java.util.zip.ZipFile 类用于从 zip 文件中读取条目。

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

Class Declaration

以下是 java.util.zip.ZipFile 类的声明 −

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

public class ZipFile
   extends Object
      implements Closeable

Fields

以下是 java.util.zip.ZipFile 类的字段 −

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

  1. static int CENATT

  2. static int CENATX

  3. static int CENCOM

  4. static int CENCRC

  5. static int CENDSK

  6. static int CENEXT

  7. static int CENFLG

  8. static int CENHDR

  9. static int CENHOW

  10. static int CENLEN

  11. static int CENNAM

  12. static int CENOFF

  13. static long CENSIG

  14. static int CENSIZ

  15. static int CENTIM

  16. static int CENVEM

  17. static int CENVER

  18. static int ENDCOM

  19. static int ENDHDR

  20. static int ENDOFF

  21. static long ENDSIG

  22. static int ENDSIZ

  23. static int ENDSUB

  24. static int ENDTOT

  25. static int EXTCRC

  26. static int EXTHDR

  27. static int EXTLEN

  28. static long EXTSIG

  29. static int EXTSIZ

  30. static int LOCCRC

  31. static int LOCEXT

  32. static int LOCFLG

  33. static int LOCHDR

  34. static int LOCHOW

  35. static int LOCLEN

  36. static int LOCNAM

  37. static long LOCSIG

  38. static int LOCSIZ

  39. static int LOCTIM

  40. static int LOCVER

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

  42. 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 −

  1. Java.lang.Object