@Test @Ignore public void testUnCompress() throws Exception { String zipFile = TestUtil.path + "temp/test.zip"; if (!(new File(zipFile).exists())) { testDeCompress(); } ZIPUtil.unCompress(new File(zipFile), TestUtil.path + "temp/unzip/"); }
public static void unCompress(File source, String path) throws IOException { ZipEntry zipEntry = null; FileUtil.createPaths(path); try ( ZipFile zipFile = new ZipFile(source); ZipInputStream zipInputStream = new ZipInputStream(new FileInputStream(source)) ) { while ((zipEntry = zipInputStream.getNextEntry()) != null) { String fileName = zipEntry.getName(); String filePath = path + "/" + fileName; if (zipEntry.isDirectory()) { File temp = new File(filePath); if (!temp.exists()) { temp.mkdirs(); } } else { File temp = new File(filePath); if (!temp.getParentFile().exists()) { temp.getParentFile().mkdirs(); } try (OutputStream os = new FileOutputStream(temp); InputStream is = zipFile.getInputStream(zipEntry)) { int len = 0; while ((len = is.read()) != -1) { os.write(len); } } catch (IOException e) { throw e; } } } } catch (IOException e) { throw e; } }
ZIPUtil { public static void unCompress(File source, String path) throws IOException { ZipEntry zipEntry = null; FileUtil.createPaths(path); try ( ZipFile zipFile = new ZipFile(source); ZipInputStream zipInputStream = new ZipInputStream(new FileInputStream(source)) ) { while ((zipEntry = zipInputStream.getNextEntry()) != null) { String fileName = zipEntry.getName(); String filePath = path + "/" + fileName; if (zipEntry.isDirectory()) { File temp = new File(filePath); if (!temp.exists()) { temp.mkdirs(); } } else { File temp = new File(filePath); if (!temp.getParentFile().exists()) { temp.getParentFile().mkdirs(); } try (OutputStream os = new FileOutputStream(temp); InputStream is = zipFile.getInputStream(zipEntry)) { int len = 0; while ((len = is.read()) != -1) { os.write(len); } } catch (IOException e) { throw e; } } } } catch (IOException e) { throw e; } } }
ZIPUtil { public static void unCompress(File source, String path) throws IOException { ZipEntry zipEntry = null; FileUtil.createPaths(path); try ( ZipFile zipFile = new ZipFile(source); ZipInputStream zipInputStream = new ZipInputStream(new FileInputStream(source)) ) { while ((zipEntry = zipInputStream.getNextEntry()) != null) { String fileName = zipEntry.getName(); String filePath = path + "/" + fileName; if (zipEntry.isDirectory()) { File temp = new File(filePath); if (!temp.exists()) { temp.mkdirs(); } } else { File temp = new File(filePath); if (!temp.getParentFile().exists()) { temp.getParentFile().mkdirs(); } try (OutputStream os = new FileOutputStream(temp); InputStream is = zipFile.getInputStream(zipEntry)) { int len = 0; while ((len = is.read()) != -1) { os.write(len); } } catch (IOException e) { throw e; } } } } catch (IOException e) { throw e; } }  }
ZIPUtil { public static void unCompress(File source, String path) throws IOException { ZipEntry zipEntry = null; FileUtil.createPaths(path); try ( ZipFile zipFile = new ZipFile(source); ZipInputStream zipInputStream = new ZipInputStream(new FileInputStream(source)) ) { while ((zipEntry = zipInputStream.getNextEntry()) != null) { String fileName = zipEntry.getName(); String filePath = path + "/" + fileName; if (zipEntry.isDirectory()) { File temp = new File(filePath); if (!temp.exists()) { temp.mkdirs(); } } else { File temp = new File(filePath); if (!temp.getParentFile().exists()) { temp.getParentFile().mkdirs(); } try (OutputStream os = new FileOutputStream(temp); InputStream is = zipFile.getInputStream(zipEntry)) { int len = 0; while ((len = is.read()) != -1) { os.write(len); } } catch (IOException e) { throw e; } } } } catch (IOException e) { throw e; } }  static void deCompress(File file, String dest); static void zipFile(File inFile, ZipOutputStream zos, String dir); static void unCompress(File source, String path); }
ZIPUtil { public static void unCompress(File source, String path) throws IOException { ZipEntry zipEntry = null; FileUtil.createPaths(path); try ( ZipFile zipFile = new ZipFile(source); ZipInputStream zipInputStream = new ZipInputStream(new FileInputStream(source)) ) { while ((zipEntry = zipInputStream.getNextEntry()) != null) { String fileName = zipEntry.getName(); String filePath = path + "/" + fileName; if (zipEntry.isDirectory()) { File temp = new File(filePath); if (!temp.exists()) { temp.mkdirs(); } } else { File temp = new File(filePath); if (!temp.getParentFile().exists()) { temp.getParentFile().mkdirs(); } try (OutputStream os = new FileOutputStream(temp); InputStream is = zipFile.getInputStream(zipEntry)) { int len = 0; while ((len = is.read()) != -1) { os.write(len); } } catch (IOException e) { throw e; } } } } catch (IOException e) { throw e; } }  static void deCompress(File file, String dest); static void zipFile(File inFile, ZipOutputStream zos, String dir); static void unCompress(File source, String path);  }