Here you can find the source of unzip(File dest, String jar)
public static void unzip(File dest, String jar) throws IOException
//package com.java2s; /******************************************************************************* * Copyright (c) 2007 Exadel, Inc. and Red Hat, Inc. * Distributed under license by Red Hat, Inc. All rights reserved. * This program is made available under the terms of the * Eclipse Public License v1.0 which accompanies this distribution, * and is available at http://www.eclipse.org/legal/epl-v10.html * * Contributors://from w w w . jav a2 s . c o m * Exadel, Inc. and Red Hat, Inc. - initial API and implementation ******************************************************************************/ 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 { public static void unzip(File dest, String jar) throws IOException { dest.mkdirs(); ZipFile zf = new ZipFile(jar); try { Enumeration es = zf.entries(); while (es.hasMoreElements()) { ZipEntry je = (ZipEntry) es.nextElement(); String n = je.getName(); File f = new File(dest, n); if (je.isDirectory()) { f.mkdirs(); } else { if (f.exists()) { f.delete(); } else { f.getParentFile().mkdirs(); } InputStream is = zf.getInputStream(je); FileOutputStream os = new FileOutputStream(f); try { copyStream(is, os); } finally { os.close(); } } long time = je.getTime(); if (time != -1) f.setLastModified(time); } } finally { zf.close(); } } public static void copyStream(InputStream is, OutputStream os) throws IOException { byte[] buffer = new byte[1 << 14]; while (true) { int r = is.read(buffer); if (r > 0) { os.write(buffer, 0, r); } else if (r == -1) break; } os.flush(); } }