Sunday, January 13, 2013

Read zip file using Java

This is a simple code to Read a zip file ........





import 
java.io.FileInputStream;
import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream;

public class Main {

  public static void main(String[] argsthrows Exception {
    FileInputStream fis = new FileInputStream("C:/MyZip.zip");
    ZipInputStream zis = new ZipInputStream(fis);
    ZipEntry ze;
    while ((ze = zis.getNextEntry()) != null) {
      System.out.println(ze.getName());
      zis.closeEntry();
    }

    zis.close();

  }
}

No comments:

Post a Comment