Here you can find the source of decompress(String zipFile, String targetPath)
public static void decompress(String zipFile, String targetPath)
//package com.java2s; /**/*from ww w .j a v a2 s. c om*/ * Copyright (c) 2015 SK holdings Co., Ltd. All rights reserved. * This software is the confidential and proprietary information of SK holdings. * You shall not disclose such confidential information and shall use it only in * accordance with the terms of the license agreement you entered into with SK holdings. * (http://www.eclipse.org/legal/epl-v10.html) */ import java.io.BufferedInputStream; import java.io.BufferedOutputStream; import java.io.File; import java.io.FileOutputStream; import java.util.Enumeration; import java.util.zip.ZipEntry; import java.util.zip.ZipFile; public class Main { public static void decompress(String zipFile, String targetPath) { int BUFFER = 2048; ZipFile zipfile = null; File root = null; try { BufferedOutputStream dest = null; BufferedInputStream is = null; ZipEntry entry; zipfile = new ZipFile(zipFile); Enumeration e = zipfile.entries(); root = new File(targetPath); File file = null; while (e.hasMoreElements()) { entry = (ZipEntry) e.nextElement(); String fileName = entry.getName();// .replaceAll("\\\\", "/"); file = new File(root, fileName); if (fileName.endsWith("/") || fileName.endsWith("\\")) { if (!file.exists()) file.mkdirs(); file = null; // continue; } else { System.out.println("Decompress File :" + file.getAbsolutePath()); is = new BufferedInputStream(zipfile.getInputStream(entry)); int count; byte data[] = new byte[BUFFER]; File p = new File(file.getParent()); if (!p.exists()) p.mkdirs(); p = null; FileOutputStream fos = new FileOutputStream(file); dest = new BufferedOutputStream(fos, BUFFER); while ((count = is.read(data, 0, BUFFER)) != -1) { dest.write(data, 0, count); } dest.flush(); dest.close(); if (fos != null) fos.close(); is.close(); } } } catch (Exception e) { } finally { root = null; try { if (zipfile != null) zipfile.close(); } catch (Exception xe) { } } } }