public static void loadLibraryFromFile ( final String directory , final String filename ) throws IOException { final String libraryPath = directory + File . separator + filename ; synchronized ( loadedLibrarySet ) { final File outputFile = new File ( directory , filename ) ; if ( ! outputFile . exists ( ) ) { // Try to extract the library from the system resources final ClassLoader cl = ClassLoader . getSystemClassLoader ( ) ; final InputStream in = cl . getResourceAsStream ( JAR_PREFIX + filename ) ; if ( in == null ) { throw new IOException ( "Unable to extract native library " + filename + " to " + directory ) ; } final OutputStream out = new FileOutputStream ( outputFile ) ; copy ( in , out ) ; } System . load ( libraryPath ) ; loadedLibrarySet . add ( filename ) ; } }
Loads a native library from a file .