Here you can find the source of unzip(File zip, File targetDir)
public static void unzip(File zip, File targetDir) throws IOException
//package com.java2s; import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.util.zip.ZipEntry; import java.util.zip.ZipInputStream; public class Main { public static void unzip(File zip, File targetDir) throws IOException { unzip(new FileInputStream(zip), targetDir); }/* ww w . j a v a 2 s. c o m*/ public static void unzip(InputStream in, File targetDir) throws IOException { ZipInputStream zipIn = null; try { zipIn = new ZipInputStream(in); byte[] b = new byte[8192]; ZipEntry zipEntry; while ((zipEntry = zipIn.getNextEntry()) != null) { File file = new File(targetDir, zipEntry.getName()); if (!zipEntry.isDirectory()) { File parent = file.getParentFile(); if (!parent.exists()) { parent.mkdirs(); } FileOutputStream fos = new FileOutputStream(file); try { int r; while ((r = zipIn.read(b)) != -1) { fos.write(b, 0, r); } } finally { fos.close(); } } else { file.mkdirs(); } zipIn.closeEntry(); } } finally { if (zipIn != null) { zipIn.close(); } in.close(); } } }