/** * Extracts zip file content to the target directory. * @see #unzip(java.io.File, java.io.File, String...) */ public static void unzip(String zipFile, String destDir, String... patterns) throws IOException { unzip(new File(zipFile), new File(destDir), patterns); }
/** * Extracts zip file content to the target directory. * @see #unzip(java.io.File, java.io.File, String...) */ public static void unzip(final String zipFile, final String destDir, final String... patterns) throws IOException { unzip(new File(zipFile), new File(destDir), patterns); }
@Test void testZipBuilderFile() throws IOException { File zipFile = new File(dataRoot, "test.zip"); ZipBuilder.createZipFile(zipFile) .add(new File(dataRoot, "sb.data")) .path("sbdata").comment("This is sb data file").save() .add(new File(dataRoot, "file")) .path("folder").comment("This is a folder and all its files").save() .toZipFile(); assertTrue(zipFile.exists()); ZipUtil.unzip(zipFile, new File(dataRoot), "sbda*"); assertTrue(new File(dataRoot, "sbdata").exists()); assertFalse(new File(dataRoot, "folder").exists()); ZipUtil.unzip(zipFile, new File(dataRoot)); assertTrue(new File(dataRoot, "sbdata").exists()); assertTrue(new File(dataRoot, "folder").exists()); assertTrue(new File(new File(dataRoot, "folder"), "a.png").exists()); // cleanup FileUtil.delete(new File(dataRoot, "sbdata")); FileUtil.deleteDir(new File(dataRoot, "folder")); FileUtil.delete(zipFile); }
ZipUtil.unzip(zipFile, new File(dataRoot));
/** * Extracts zip file content to the target directory. * @see #unzip(java.io.File, java.io.File, String...) */ public static void unzip(final String zipFile, final String destDir, final String... patterns) throws IOException { unzip(new File(zipFile), new File(destDir), patterns); }