Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

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("ziptest.zip");

        // Get the enumeration for all zip entries and loop through them
        Enumeration<? extends ZipEntry> e = zf.entries();
        ZipEntry entry = null;

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

            // Get the input stream for the current zip entry
            InputStream is = zf.getInputStream(entry);

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

            // Print the name of the entry
            System.out.println(entry.getName());
        }

    }
}