Sample code for 30+ languages & platforms
Java Requires Chilkat v11.0.0+

List Files in a .zip

See more Zip Examples

How to list files within a .zip

Chilkat Java Downloads

Chilkat2 Java
import com.chilkatsoft.chilkat2.ChilkatException;
import com.chilkatsoft.chilkat2.Zip;
import com.chilkatsoft.chilkat2.ZipEntry;

public class ChilkatExample {

    public static void main(String[] args) {
        // This example requires the Chilkat API to have been previously unlocked.
        // See Global Unlock Sample for sample code.

        Zip zip = new Zip();

        try {
            zip.openZip("a.zip");
        } catch (ChilkatException e) {
            System.out.println(e.getLastErrorText());
            return;
        }

        // Get the number of files and directories in the .zip
        int n = zip.getNumEntries();

        ZipEntry entry = new ZipEntry();

        int i = 0;

        while (i < n) {
            zip.entryAt(i, entry);
            if (!entry.getIsDirectory()) {
                // (the filename may include a path)
                System.out.println(entry.getFileName());
            }

            i = i + 1;
        }
    }
}