Java ZipFile get ZipEntry Enumeration

Description

Java ZipFile get ZipEntry Enumeration



import java.io.InputStream;
import java.util.Enumeration;
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;

public class Main {
  public static void main(String[] args) throws Exception {
    ZipFile zf = new ZipFile("Main.zip");

    Enumeration<? extends ZipEntry> e = zf.entries();
    ZipEntry entry = null;//from ww  w  . j av a 2 s . c  o  m

    while (e.hasMoreElements()) {
      entry = e.nextElement();

      InputStream is = zf.getInputStream(entry);

      /* Read data for the entry using the is object */

      System.out.println(entry.getName());
      is.close();
    }
    zf.close();
  }
}



PreviousNext

Related