Here you can find the source of unzip(File zip, File directory)
public static void unzip(File zip, File directory) throws ZipException, IOException
//package com.java2s; //License from project: Apache License import java.io.BufferedInputStream; import java.io.BufferedOutputStream; import java.io.File; import java.io.FileOutputStream; import java.io.IOException; import java.util.Enumeration; import java.util.zip.ZipEntry; import java.util.zip.ZipException; import java.util.zip.ZipFile; public class Main { public static void unzip(File zip, File directory) throws ZipException, IOException { ZipFile zipFile = new ZipFile(zip); try {//from w ww. j a v a 2 s. com Enumeration<? extends ZipEntry> entries = zipFile.entries(); while (entries.hasMoreElements()) { ZipEntry zipEntry = entries.nextElement(); if (zipEntry.isDirectory()) { File temp = new File(directory + File.separator + zipEntry.getName()); temp.mkdirs(); continue; } BufferedInputStream bis = new BufferedInputStream(zipFile.getInputStream(zipEntry)); File f = new File(directory + File.separator + zipEntry.getName()); File f_p = f.getParentFile(); if (f_p != null && !f_p.exists()) { f_p.mkdirs(); } BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(f)); int len = -1; byte[] bs = new byte[2048]; while ((len = bis.read(bs, 0, 2048)) != -1) { bos.write(bs, 0, len); } bos.flush(); bos.close(); bis.close(); } } finally { zipFile.close(); } } }