Get Zip Entry - Java File Path IO

Java examples for File Path IO:Zip File

Description

Get Zip Entry

Demo Code

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

public class Main {

  public static void main(String args[]) {
    try {//from   ww  w  . j ava2 s .  c om
      ZipFile zipFile = new ZipFile("c:/Folder/WebFiles.zip");

      Enumeration e = zipFile.entries();

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

        String comment = entry.getComment();

        if ("".equals(comment))
          System.out.println(comment + " found for entry " + entry.getName());
        else
          System.out.println("No comments found for entry " + entry.getName());
      }
      zipFile.close();

    } catch (IOException ioe) {
      System.out.println("Error opening zip file" + ioe);
    }
  }
}

Result


Related Tutorials