Here you can find the source of unZip(String zipFile, String targetPath)
public static boolean unZip(String zipFile, String targetPath)
//package com.java2s; import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; import java.util.zip.ZipEntry; import java.util.zip.ZipInputStream; public class Main { public static boolean unZip(String zipFile, String targetPath) { //create target location folder if not exist createDir(targetPath, ""); try {//from ww w.j av a 2 s. c o m FileInputStream fin = new FileInputStream(zipFile); ZipInputStream zin = new ZipInputStream(fin); ZipEntry ze = null; while ((ze = zin.getNextEntry()) != null) { //create dir if required while unzipping if (ze.isDirectory()) { createDir(targetPath, ze.getName()); } else { FileOutputStream fout = new FileOutputStream(targetPath + ze.getName()); for (int c = zin.read(); c != -1; c = zin.read()) { fout.write(c); } zin.closeEntry(); fout.close(); } } zin.close(); return true; } catch (Exception e) { System.out.println(e); } return false; } private static void createDir(String path, String folder) { File f = new File(path + folder); if (!f.isDirectory()) { f.mkdirs(); } } }