public static void extractFile ( JarFile jar , JarEntry entry , File destPath ) throws IOException { InputStream in = null ; OutputStream out = null ; try { in = jar . getInputStream ( entry ) ; out = new FileOutputStream ( destPath ) ; byte [ ] buf = new byte [ 1024 ] ; for ( int i = in . read ( buf ) ; i != - 1 ; i = in . read ( buf ) ) { out . write ( buf , 0 , i ) ; } } finally { if ( in != null ) { in . close ( ) ; } if ( out != null ) { out . close ( ) ; } } //Ensure persmissions are set correct on ascp, has to be done after the File has been created if ( entry . getName ( ) . equals ( "ascp" ) ) { destPath . setExecutable ( true ) ; destPath . setWritable ( true ) ; } }
Extracts a jar entry from a jar file to a target location on the local file system