Here you can find the source of unzip(File destDir, InputStream is)
public static void unzip(File destDir, InputStream is)
//package com.java2s; //License from project: Open Source License import java.io.BufferedOutputStream; import java.io.File; import java.io.FileOutputStream; import java.io.InputStream; import java.util.zip.ZipEntry; import java.util.zip.ZipInputStream; public class Main { public static void unzip(File destDir, InputStream is) { final int BUFFER = 2048; try {//from w w w . j a v a 2 s .co m BufferedOutputStream dest = null; ZipInputStream zis = new ZipInputStream(is); ZipEntry entry; while ((entry = zis.getNextEntry()) != null) { //System.out.println("Extracting: " + entry); File destinationFilePath = new File(destDir, entry.getName()); // create directories if required. destinationFilePath.getParentFile().mkdirs(); if (!entry.isDirectory()) { int count; byte data[] = new byte[BUFFER]; // write the files to the disk FileOutputStream fos = new FileOutputStream(destinationFilePath); dest = new BufferedOutputStream(fos, BUFFER); while ((count = zis.read(data, 0, BUFFER)) != -1) { dest.write(data, 0, count); } dest.flush(); dest.close(); } } zis.close(); } catch (Exception e) { e.printStackTrace(); } } }