private void extractInternalFiles ( ) throws IOException { Enumeration entries = _h2oJar . entries ( ) ; while ( entries . hasMoreElements ( ) ) { ZipEntry e = ( ZipEntry ) entries . nextElement ( ) ; String name = e . getName ( ) ; if ( e . isDirectory ( ) ) continue ; // mkdirs() will handle these if ( ! name . endsWith ( ".jar" ) ) continue ; // extract the entry File out = internalFile ( name ) ; out . getParentFile ( ) . mkdirs ( ) ; try { FileOutputStream fos = new FileOutputStream ( out ) ; BufferedInputStream is = new BufferedInputStream ( _h2oJar . getInputStream ( e ) ) ; BufferedOutputStream os = new BufferedOutputStream ( fos ) ; int read ; byte [ ] buffer = new byte [ 4096 ] ; while ( ( read = is . read ( buffer ) ) != - 1 ) os . write ( buffer , 0 , read ) ; os . flush ( ) ; fos . getFD ( ) . sync ( ) ; // Force the output; throws SyncFailedException if full os . close ( ) ; is . close ( ) ; } catch ( FileNotFoundException ex ) { // Expected FNF if 2 H2O instances are attempting to unpack in the same directory } catch ( IOException ex ) { Log . die ( "Unable to extract file " + name + " because of " + ex + ". Make sure that directory " + _parentDir + " contains at least 50MB of free space to unpack H2O libraries." ) ; throw ex ; // dead code } } }
Extracts the libraries from the jar file to given local path .