Here you can find the source of unzipEntry(ZipFile zipfile, ZipEntry entry, File outputDir)
private static void unzipEntry(ZipFile zipfile, ZipEntry entry, File outputDir) throws IOException
//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.zip.ZipEntry; import java.util.zip.ZipFile; public class Main { private static void unzipEntry(ZipFile zipfile, ZipEntry entry, File outputDir) throws IOException { File outputFile = new File(outputDir, entry.getName()); if (entry.isDirectory()) { outputFile.mkdirs();/*w w w . java 2s . co m*/ return; } if (!outputFile.getParentFile().exists()) { outputFile.getParentFile().mkdirs(); } BufferedInputStream inputStream = new BufferedInputStream( zipfile.getInputStream(entry)); BufferedOutputStream outputStream = new BufferedOutputStream( new FileOutputStream(outputFile)); try { byte[] buf = new byte[1024 * 1024]; int k; while ((k = inputStream.read(buf)) != -1) { outputStream.write(buf, 0, k); outputStream.flush(); } } finally { try { outputStream.close(); } catch (Exception e) { e.printStackTrace(); } try { inputStream.close(); } catch (Exception e) { e.printStackTrace(); } } } }