Here you can find the source of unzip(String sZip)
Parameter | Description |
---|---|
sZip | Nama file zip |
public static void unzip(String sZip)
//package com.java2s; //License from project: Open Source License import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; import java.util.zip.ZipEntry; import java.util.zip.ZipInputStream; public class Main { /**//from w ww . j a va 2 s . c o m * Unzip file Zip (terkompresi) * @param sZip Nama file zip */ public static void unzip(String sZip) { byte[] buf = new byte[1024]; try { // Membuka file Zip ZipInputStream zin = new ZipInputStream(new FileInputStream( sZip)); ZipEntry ze; // Iterasi dan mendapatkan file while ((ze = zin.getNextEntry()) != null) { FileOutputStream out = new FileOutputStream(ze.getName()); int len; // Transfer byte dari file Zip ke output file while ((len = zin.read(buf)) > 0) { out.write(buf, 0, len); } // Bersihkan resource out.close(); System.out.println("Unzip " + ze.getName() + " [ok]"); } // Bersihkan resource zin.close(); } catch (IOException ex) { System.err.println(ex.getMessage()); } } }