public static void load ( final String aNativeLibrary ) throws IOException { final String libFileName = getPlatformLibraryName ( aNativeLibrary ) ; final File tmpDir = new File ( System . getProperty ( "java.io.tmpdir" ) ) ; final File libFile = new File ( tmpDir , libFileName ) ; // Check to see whether it already exists before we go creating it again? if ( ! libFile . exists ( ) || libFile . length ( ) == 0 ) { final URL url = ClasspathUtils . findFirst ( libFileName ) ; if ( url == null ) { throw new FileNotFoundException ( LOGGER . getMessage ( MessageCodes . UTIL_002 , aNativeLibrary ) ) ; } final JarFile jarFile = new JarFile ( url . getFile ( ) ) ; final JarEntry jarEntry = jarFile . getJarEntry ( libFileName ) ; final InputStream inStream = jarFile . getInputStream ( jarEntry ) ; final BufferedOutputStream outStream = new BufferedOutputStream ( new FileOutputStream ( libFile ) ) ; IOUtils . copyStream ( inStream , outStream ) ; IOUtils . closeQuietly ( inStream ) ; IOUtils . closeQuietly ( outStream ) ; IOUtils . closeQuietly ( jarFile ) ; } if ( libFile . exists ( ) && libFile . length ( ) > 0 ) { System . load ( libFile . getAbsolutePath ( ) ) ; } else { throw new IOException ( LOGGER . getI18n ( MessageCodes . UTIL_039 , libFile ) ) ; } }
Loads a native library from the classpath .