import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream;

public class Unzip {
	final static int BUFFER = 2048;

	/**
	 * Unzip a zip archive file into a directory by the same
	 * name as the original zip file (minus the extension);
	 * @param f - File to unarchive
	 * @return Array of file names that were unpacked
	 */
	public static ArrayList<String> unzip(File f) throws IOException
	{
		ArrayList<String> unpackedFiles = new ArrayList<String>();
		String subdir = f.getName();
		int dotOffset = subdir.lastIndexOf('.');
		if (dotOffset != -1)
		{
			subdir = subdir.substring(0, dotOffset);
		}
		File subdirFile = new File(f.getParent() + File.separator + subdir);
		if (!subdirFile.mkdir())
		{
			throw new IOException("Could not create directory: " + subdirFile.getAbsolutePath());
		}
		/*
		 * From:
		 * http://java.sun.com/developer/technicalArticles/Programming/compression/
		 */
		BufferedOutputStream dest = null;
		FileInputStream fis = new 
				FileInputStream(f);
		ZipInputStream zis = new 
				ZipInputStream(new BufferedInputStream(fis));
		ZipEntry entry;
		while((entry = zis.getNextEntry()) != null) {
			//System.out.println("Extracting: " +entry);
			int count;
			byte data[] = new byte[BUFFER];
			// write the files to the disk
			String newFileName = subdir + File.separator + entry.getName();
			unpackedFiles.add(newFileName);
			FileOutputStream fos = new 
					FileOutputStream(f.getParent() + File.separator + newFileName);
			dest = new 
					BufferedOutputStream(fos, BUFFER);
			while ((count = zis.read(data, 0, BUFFER)) != -1) {
				dest.write(data, 0, count);
			}
			dest.flush();
			dest.close();
		}
		zis.close();
		return unpackedFiles;
	}
}

@@ -1307,16 +1307,17 @@
 %0A%09%09while
+ 
 ((entry 
@@ -1349,16 +1349,232 @@
 null) %7B%0A
+%09%09%09if (entry.isDirectory())%0A%09%09%09%7B%0A%09%09%09%09String newDirName = subdir + File.separator + entry.getName();%0A%09%09%09%09File newDir = new File(f.getParent() + File.separator + newDirName);%0A%09%09%09%09newDir.mkdirs();%09%09%09%0A%09%09%09%7D%0A%09%09%09else%0A%09%09%09%7B%0A%09
 %09%09%09//Sys
@@ -1616,16 +1616,17 @@
 ry);%0A%09%09%09
+%09
 int coun
@@ -1628,16 +1628,17 @@
  count;%0A
+%09
 %09%09%09byte 
@@ -1667,16 +1667,17 @@
 ER%5D;%0A%09%09%09
+%09
 // write
@@ -1699,16 +1699,17 @@
 he disk%0A
+%09
 %09%09%09Strin
@@ -1767,16 +1767,17 @@
 Name();%0A
+%09
 %09%09%09unpac
@@ -1810,57 +1810,32 @@
 %0A%09%09%09
+%09
 File
-OutputStream fos = new %0A%09%09%09%09%09FileOutputStream
+ newFile = new File
 (f.g
@@ -1878,16 +1878,113 @@
 eName);%0A
+%09%09%09%09newFile.getParentFile().mkdirs();%0A%09%09%09%09FileOutputStream fos = new FileOutputStream(newFile);%0A%09
 %09%09%09dest 
@@ -1995,16 +1995,17 @@
 w %0A%09%09%09%09%09
+%09
 Buffered
@@ -2031,16 +2031,17 @@
 UFFER);%0A
+%09
 %09%09%09while
@@ -2087,16 +2087,17 @@
 = -1) %7B%0A
+%09
 %09%09%09%09dest
@@ -2123,18 +2123,20 @@
 nt);%0A%09%09%09
+%09
 %7D%0A
+%09
 %09%09%09dest.
@@ -2144,16 +2144,17 @@
 lush();%0A
+%09
 %09%09%09dest.
@@ -2162,16 +2162,21 @@
 lose();%0A
+%09%09%09%7D%0A
 %09%09%7D%0A%09%09zi

Handle directory entries in zip files.