question: public static void unzip ( InputStream in , Path destDir ) throws IOException { in = new BufferedInputStream ( in ) ; try ( ZipInputStream zipInput = new ZipInputStream ( in ) ) { ZipEntry entry ; byte [ ] buffer = new byte [ 8192 ] ; while ( ( entry = zipInput . getNextEntry ( ) ) != null ) { Path targetFile = destDir . resolve ( entry . getName ( ) ) ; Files . createDirectories ( targetFile . getParent ( ) ) ; if ( ! entry . isDirectory ( ) ) { OutputStream out = Files . newOutputStream ( targetFile ) ; int len ; while ( ( len = zipInput . read ( buffer ) ) >= 0 ) { out . write ( buffer , 0 , len ) ; } out . close ( ) ; } zipInput . closeEntry ( ) ; } } }
target:  Convenience method unzipping zipName into destDir. You must pass it a clean destDir. Closes the given InputStream after extracting! 