Listing the files that are contained in a Zip file

Extremely simple! Create an instance of ZipFile and enumerate its ZipEntries:

import java.io.*;
import java.util.*;
import java.util.zip.*;
 
public class Main
{
   public static void main(String[] args) throws IOException 
   {
      if (args.length != 1) {
         System.out.println("Usage: java Main <file.zip>");
         System.exit(1);
      }
 
      listContents(args[0]);
   }
 
   public static void listContents(String zipfilename) throws IOException {
      ZipFile zip = new ZipFile(zipfilename);
 
      for (Enumeration e=zip.entries(); e.hasMoreElements(); ) {
         ZipEntry ze = (ZipEntry) e.nextElement();
         System.out.println(ze.getName());
      }
   }
}

Sample output of esustools.zip:

com/
com/esus/
com/esus/security/
com/esus/security/DES.java
com/esus/security/MD5.java
com/esus/security/MD5.class
com/esus/security/KeyUtils.java
com/esus/security/KeyUtils.class
com/esus/security/DES.class
com/esus/security/CryptException.java
com/esus/security/CryptException.class
...