Here you can find the source of unZip(String zipFile, String outputFolder, boolean skipDirectory)
public static void unZip(String zipFile, String outputFolder, boolean skipDirectory)
//package com.java2s; //License from project: Open Source License import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; import java.nio.charset.Charset; import java.util.zip.ZipEntry; import java.util.zip.ZipInputStream; public class Main { public static void unZip(String zipFile, String outputFolder, boolean skipDirectory) { byte[] buffer = new byte[1024]; try {//from w w w .j a v a2 s . co m ZipInputStream zis = new ZipInputStream(new FileInputStream(zipFile), Charset.forName("EUC-KR")); ZipEntry ze = zis.getNextEntry(); while (ze != null) { String fileName = ze.getName(); if (!ze.isDirectory() && isAllowedFileName(fileName)) { String path = ""; if (skipDirectory) path = outputFolder + File.separator + fileName.substring(fileName.indexOf("/")); else path = outputFolder + File.separator + fileName; File newFile = new File(path); new File(newFile.getParent()).mkdirs(); FileOutputStream fos = new FileOutputStream(newFile); int len; while ((len = zis.read(buffer)) > 0) { fos.write(buffer, 0, len); } fos.close(); } ze = zis.getNextEntry(); } zis.closeEntry(); zis.close(); } catch (IOException ex) { System.out.println(ex.getLocalizedMessage()); } } public static boolean isAllowedFileName(String fileName) { fileName = fileName.toLowerCase(); if (fileName.contains(".git/") || fileName.contains("debug/") || fileName.contains("classes/") || fileName.contains("gen-external-apklibs/") || fileName.contains("release/") || fileName.endsWith(".exe") || fileName.endsWith(".ipch") || fileName.endsWith(".sdf") || fileName.endsWith(".bak") || fileName.endsWith(".log") || fileName.endsWith(".pyc") || fileName.endsWith(".pyd") || fileName.endsWith(".opensdf") || fileName.endsWith(".ilk") || fileName.endsWith(".pyo") || fileName.endsWith(".lib") || fileName.endsWith(".class") || fileName.endsWith(".dex") || fileName.endsWith(".bak") || fileName.endsWith(".tlb") || fileName.endsWith(".class") || fileName.endsWith(".dex") || fileName.endsWith(".ap_") || fileName.endsWith(".apk")) return false; return true; } }