ZipUtil { public static void unzipToDir(File zipFile, File toDir) throws IOException { try (FileInputStream fis = new FileInputStream(zipFile)) { unzipToDir(fis, toDir); } }  static void createZip(Collection<ItemToArchive> items, File outputFile); static void unzipToDir(File zipFile, File toDir); static void unzipToDir(InputStream is, File toDir);  }
@Test public void testUnzipStrings() throws Exception { final File archive = File.createTempFile(getClass().getSimpleName(), "zip"); final ZipOutputStream zipStream = new ZipOutputStream(new BufferedOutputStream(new FileOutputStream(archive))); for(Map.Entry<String,String> entry: stringContents.entrySet()) { zipStream.putNextEntry(new ZipArchiveEntry(entry.getKey())); final byte [] bytes = entry.getValue().getBytes(); zipStream.write(bytes,0,bytes.length); zipStream.closeEntry(); } zipStream.close(); final File destDir = tmpFolder.newFolder(); ZipUtil.unzipToDir(archive, destDir); assertFSContentCorrespondsWithMap(destDir, stringContents); }