Here you can find the source of unzip(String sourceFile, String toDir)
public static void unzip(String sourceFile, String toDir) throws Exception
//package com.java2s; import java.io.*; import java.util.*; import java.util.zip.ZipEntry; import java.util.zip.ZipFile; import com.google.common.io.ByteStreams; import com.google.common.io.Closeables; public class Main { public static void unzip(String sourceFile, String toDir) throws Exception { ZipFile zipFile = new ZipFile(sourceFile); Enumeration<? extends ZipEntry> entries = zipFile.entries(); while (entries.hasMoreElements()) { ZipEntry entry = entries.nextElement(); File entryDestination = new File(toDir, entry.getName()); entryDestination.getParentFile().mkdirs(); if (entry.isDirectory()) entryDestination.mkdirs(); else { InputStream in = null; OutputStream out = null; try { in = zipFile.getInputStream(entry); out = new FileOutputStream(entryDestination); ByteStreams.copy(in, out); } finally { Closeables.close(in, true); Closeables.close(out, true); }/*w w w . j a v a 2 s . c om*/ } } Closeables.close(zipFile, true); } }