Here you can find the source of unzip(File input, File outputDir)
public static void unzip(File input, File outputDir)
//package com.java2s; //License from project: Open Source 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.ZipFile; public class Main { public static void unzip(File input, File outputDir) { try {//from w w w . j a v a 2s. co m if (!outputDir.exists()) outputDir.mkdir(); ZipFile zipFile = new ZipFile(input); Enumeration e = zipFile.entries(); while (e.hasMoreElements()) { ZipEntry entry = (ZipEntry) e.nextElement(); File destinationFilePath = new File(outputDir, entry.getName()); destinationFilePath.getParentFile().mkdirs(); if (!entry.isDirectory()) { BufferedInputStream bis = new BufferedInputStream(zipFile.getInputStream(entry)); int b; byte buffer[] = new byte[1024]; FileOutputStream fos = new FileOutputStream(destinationFilePath); BufferedOutputStream bos = new BufferedOutputStream(fos, 1024); while ((b = bis.read(buffer, 0, 1024)) != -1) { bos.write(buffer, 0, b); } bos.flush(); bos.close(); bis.close(); } } } catch (IOException ioe) { } } }