private void unzip ( final File file , final String outputDir ) throws IOException { try ( final ZipFile zipFile = new ZipFile ( file ) ) { final Enumeration < ? extends ZipEntry > entries = zipFile . entries ( ) ; while ( entries . hasMoreElements ( ) ) { final ZipEntry entry = entries . nextElement ( ) ; final File targetFile = new File ( outputDir , entry . getName ( ) ) ; if ( entry . isDirectory ( ) ) { targetFile . mkdirs ( ) ; } else { targetFile . getParentFile ( ) . mkdirs ( ) ; InputStream in = zipFile . getInputStream ( entry ) ; try ( OutputStream out = new FileOutputStream ( targetFile ) ) { IOUtils . copy ( in , out ) ; IOUtils . closeQuietly ( in ) ; } } } } }
Unzip given file to given output directory .