Here you can find the source of unzipZipFile(ZipFile zip, String directory)
@SuppressWarnings("unchecked") private static Collection<String> unzipZipFile(ZipFile zip, String directory) throws FileNotFoundException, IOException
//package com.java2s; /*L/* w ww . j ava 2s . com*/ * Copyright The General Hospital Corporation d/b/a Massachusetts General Hospital * * Distributed under the OSI-approved BSD 3-Clause License. * See http://ncip.github.com/digital-model-repository/LICENSE.txt for details. */ import java.io.BufferedOutputStream; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.util.ArrayList; import java.util.Collection; import java.util.Enumeration; import java.util.zip.ZipEntry; import java.util.zip.ZipFile; public class Main { @SuppressWarnings("unchecked") private static Collection<String> unzipZipFile(ZipFile zip, String directory) throws FileNotFoundException, IOException { Collection<String> returnCollection = new ArrayList<String>(); Enumeration<ZipEntry> entries = (Enumeration<ZipEntry>) zip.entries(); while (entries.hasMoreElements()) { ZipEntry entry = (ZipEntry) entries.nextElement(); copyInputStream(zip.getInputStream(entry), new BufferedOutputStream( new FileOutputStream(directory + System.getProperty("file.separator") + entry.getName()))); returnCollection.add(entry.getName()); } zip.close(); return returnCollection; } private static final void copyInputStream(InputStream in, OutputStream out) throws IOException { byte[] buffer = new byte[1024]; int len; while ((len = in.read(buffer)) >= 0) out.write(buffer, 0, len); in.close(); out.close(); } }