public static void unzip ( InputStream in , File toDir ) throws IOException { ZipInputStream zis = new ZipInputStream ( new BufferedInputStream ( in ) ) ; try { ZipEntry entry = zis . getNextEntry ( ) ; while ( entry != null ) { if ( ! entry . isDirectory ( ) ) { String entryName = entry . getName ( ) ; File toFile = new File ( toDir , entryName ) ; toFile . getParentFile ( ) . mkdirs ( ) ; OutputStream os = new FileOutputStream ( toFile ) ; try { try { copy ( zis , os ) ; } finally { zis . closeEntry ( ) ; } } finally { closeQuietly ( os ) ; } } entry = zis . getNextEntry ( ) ; } } finally { closeQuietly ( zis ) ; } }
Unzips the given input stream of a ZIP to the given directory