Here you can find the source of unzipFile(String zipFilePath, String releasePath)
@SuppressWarnings("unchecked") public static void unzipFile(String zipFilePath, String releasePath) throws IOException
//package com.java2s; //License from project: LGPL import java.io.File; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.util.Enumeration; import java.util.zip.ZipEntry; import java.util.zip.ZipFile; public class Main { @SuppressWarnings("unchecked") public static void unzipFile(String zipFilePath, String releasePath) throws IOException { ZipFile zipFile = new ZipFile(zipFilePath); Enumeration<ZipEntry> enumeration = (Enumeration<ZipEntry>) zipFile.entries(); InputStream inputStream = null; FileOutputStream fileOutputStream = null; ZipEntry zipEntry = null; String zipEntryNameStr = ""; String[] zipEntryNameArray = null; while (enumeration.hasMoreElements()) { zipEntry = enumeration.nextElement(); zipEntryNameStr = zipEntry.getName(); zipEntryNameArray = zipEntryNameStr.split("/"); String path = releasePath; File root = new File(releasePath); if (!root.exists()) { root.mkdir();// www . j ava 2 s . c o m } for (int i = 0; i < zipEntryNameArray.length; i++) { if (i < zipEntryNameArray.length - 1) { path = path + File.separator + zipEntryNameArray[i]; new File(path).mkdir(); } else { if (zipEntryNameStr.endsWith(File.separator)) { new File(releasePath + zipEntryNameStr).mkdir(); } else { inputStream = zipFile.getInputStream(zipEntry); fileOutputStream = new FileOutputStream(new File(releasePath + zipEntryNameStr)); byte[] buf = new byte[1024]; int len; while ((len = inputStream.read(buf)) > 0) { fileOutputStream.write(buf, 0, len); } inputStream.close(); fileOutputStream.close(); } } } } zipFile.close(); } }