Here you can find the source of unZip(File zipf, String targetDir)
@SuppressWarnings("rawtypes") public static void unZip(File zipf, String targetDir) throws IOException
//package com.java2s; /**//from w w w .j a v a 2 s. com * Copyright (c)2010-2011 Enterprise Website Content Management System(EWCMS), All rights reserved. * EWCMS PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. * http://www.ewcms.com */ import java.io.BufferedInputStream; import java.io.BufferedOutputStream; import java.io.File; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.util.Enumeration; import java.util.zip.ZipEntry; import java.util.zip.ZipFile; public class Main { @SuppressWarnings("rawtypes") public static void unZip(File zipf, String targetDir) throws IOException { ZipFile zfile = new ZipFile(zipf); Enumeration zList = zfile.entries(); ZipEntry ze = null; byte[] buf = new byte[1024]; while (zList.hasMoreElements()) { ze = (ZipEntry) zList.nextElement(); if (ze.isDirectory()) { File f = new File(String.format("%s/%s", targetDir, ze.getName())); f.mkdir(); continue; } OutputStream os = new BufferedOutputStream( new FileOutputStream(String.format("%s/%s", targetDir, ze.getName()))); InputStream is = new BufferedInputStream(zfile.getInputStream(ze)); int readLen = 0; while ((readLen = is.read(buf, 0, 1024)) != -1) { os.write(buf, 0, readLen); } is.close(); os.close(); } zfile.close(); } }