Unzip using the ZipInputStream : ZipInputStream « File « Java Tutorial






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

public class MainClass {

  public static void main(String[] args) throws IOException {

    for (int i = 0; i < args.length; i++) {
      FileInputStream fin = new FileInputStream(args[i]);
      ZipInputStream zin = new ZipInputStream(fin);
      ZipEntry ze = null;
      while ((ze = zin.getNextEntry()) != null) {
        System.out.println("Unzipping " + ze.getName());
        FileOutputStream fout = new FileOutputStream(ze.getName());
        for (int c = zin.read(); c != -1; c = zin.read()) {
          fout.write(c);
        }
        zin.closeEntry();
        fout.close();
      }
      zin.close();
    }
  }
}








11.61.ZipInputStream
11.61.1.Create ZipInputStream from FileInputStream
11.61.2.Unzip using the ZipInputStream
11.61.3.Read zip file with ZipInputStream
11.61.4.Decompress a zip file using ZipInputStream