Java IO Tutorial - Java ZipFile OPEN_READ








Syntax

ZipFile.OPEN_READ has the following syntax.

public static final int OPEN_READ

Example

In the following code shows how to use ZipFile.OPEN_READ field.

import java.io.File;
import java.util.Enumeration;
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;
// www .  j a  v a  2  s.  c o  m
public class Main {

  public static void main(String[] args) throws Exception {
    ZipFile zipFile = new ZipFile(new File("testfile.zip"),ZipFile.OPEN_READ);

    Enumeration zipEntries = zipFile.entries();

    while (zipEntries.hasMoreElements()) {
      System.out.println(((ZipEntry) zipEntries.nextElement()).getName());
    }
  }
}