public static void explodeJar ( JarFile jarFile , String destDir ) throws IOException { Enumeration < java . util . jar . JarEntry > enu = jarFile . entries ( ) ; while ( enu . hasMoreElements ( ) ) { JarEntry je = enu . nextElement ( ) ; File fl = new File ( destDir , je . getName ( ) ) ; if ( ! fl . exists ( ) ) { fl . getParentFile ( ) . mkdirs ( ) ; fl = new File ( destDir , je . getName ( ) ) ; } if ( je . isDirectory ( ) ) { continue ; } InputStream is = null ; try { is = jarFile . getInputStream ( je ) ; Files . copy ( is , fl . toPath ( ) , StandardCopyOption . REPLACE_EXISTING ) ; } finally { if ( is != null ) { is . close ( ) ; } } } }
Extracts a jar file into a target destination directory