Example usage for java.util.zip ZipFile ZipFile

List of usage examples for java.util.zip ZipFile ZipFile

Introduction

In this page you can find the example usage for java.util.zip ZipFile ZipFile.

Prototype

public ZipFile(File file) throws ZipException, IOException 

Source Link

Document

Opens a ZIP file for reading given the specified File object.

Usage

From source file:Main.java

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

    for (Enumeration entries = zf.entries(); entries.hasMoreElements();) {
        String zipEntryName = ((ZipEntry) entries.nextElement()).getName();
    }//from  w w w.java 2 s.  c  o  m
}

From source file:Main.java

public static void main(String[] argv) throws Exception {
    ZipFile sourcefile = new ZipFile("source.zip");

    for (Enumeration entries = sourcefile.entries(); entries.hasMoreElements();) {
        String zipEntryName = ((ZipEntry) entries.nextElement()).getName();
        System.out.println(zipEntryName);
    }/*from w  w  w .  j  a  va  2 s .c  o  m*/
}

From source file:Main.java

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

    Enumeration zipEntries = zipFile.entries();

    while (zipEntries.hasMoreElements()) {
        System.out.println(((ZipEntry) zipEntries.nextElement()).getName());
    }//from  w  ww  .  j a v a  2 s.  c om
}

From source file:Main.java

public static void main(String[] args) throws Exception {
    ZipFile zf = new ZipFile("your.zip");
    Enumeration e = zf.entries();
    while (e.hasMoreElements()) {
        ZipEntry ze = (ZipEntry) e.nextElement();
        String name = ze.getName();

        long crc = ze.getCrc();
        System.out.println("Its CRC is " + crc);

        String comment = ze.getComment();
        if (comment != null && !comment.equals("")) {
            System.out.println(comment);
        }//from w w w. j av a 2  s  .  co  m
        if (ze.isDirectory()) {
            System.out.println(name + " is a directory");
        }
    }
}

From source file:Main.java

public static void main(String[] args) throws Exception {
    ZipFile zipFile = new ZipFile(new File("testfile.zip"));

    Enumeration zipEntries = zipFile.entries();

    while (zipEntries.hasMoreElements()) {
        System.out.println(((ZipEntry) zipEntries.nextElement()).getName());
    }//  w  w w. j  ava 2s  .c o  m
}

From source file:MainClass.java

public static void main(String[] args) throws IOException {
    ZipFile zf = new ZipFile("test.zip");
    Enumeration e = zf.entries();
    while (e.hasMoreElements()) {
        ZipEntry ze2 = (ZipEntry) e.nextElement();
        System.out.println("File: " + ze2);
    }//ww w . j av  a  2s.com
}

From source file:Main.java

public static void main(String[] args) throws Exception {
    String zipname = "data.zip";
    ZipFile zipFile = new ZipFile(zipname);
    Enumeration enumeration = zipFile.entries();
    while (enumeration.hasMoreElements()) {
        ZipEntry zipEntry = (ZipEntry) enumeration.nextElement();
        System.out.println(zipEntry.getCrc());
    }//from  ww  w. ja v  a  2s.  c o  m
}

From source file:Main.java

public static void main(String[] args) throws Exception {
    String zipname = "data.zip";
    ZipFile zipFile = new ZipFile(zipname);
    Enumeration enumeration = zipFile.entries();
    while (enumeration.hasMoreElements()) {
        ZipEntry zipEntry = (ZipEntry) enumeration.nextElement();
        System.out.println(zipEntry.toString());
    }//  ww  w  .j a va2  s .co m
}

From source file:Main.java

public static void main(String[] args) throws Exception {
    String zipname = "data.zip";
    ZipFile zipFile = new ZipFile(zipname);
    Enumeration enumeration = zipFile.entries();
    while (enumeration.hasMoreElements()) {
        ZipEntry zipEntry = (ZipEntry) enumeration.nextElement();
        System.out.println(zipEntry.getMethod() == ZipEntry.STORED);
    }/*  ww  w . j  av  a2 s .  c o m*/
}

From source file:Main.java

public static void main(String[] args) throws Exception {
    String zipname = "data.zip";
    ZipFile zipFile = new ZipFile(zipname);
    Enumeration enumeration = zipFile.entries();
    while (enumeration.hasMoreElements()) {
        ZipEntry zipEntry = (ZipEntry) enumeration.nextElement();
        System.out.println(zipEntry.clone());
    }/*from   w  w  w  .  j  a v a  2 s . c  o m*/
}