public static void load ( URL filename ) throws IOException { // Silently ignore loading query if ( disable ) { return ; } if ( URISchemeType . FILE . isURL ( filename ) ) { try { load ( new File ( filename . toURI ( ) ) ) ; } catch ( URISyntaxException e ) { throw new FileNotFoundException ( filename . toExternalForm ( ) ) ; } } else { // Create a tmp file to receive the library code. final String libName = System . mapLibraryName ( "javaDynLib" ) ; //$NON-NLS-1$ String suffix = ".dll" ; //$NON-NLS-1$ String prefix = "javaDynLib" ; //$NON-NLS-1$ final int pos = libName . lastIndexOf ( ' ' ) ; if ( pos >= 0 ) { suffix = libName . substring ( pos ) ; prefix = libName . substring ( 0 , pos ) ; } final File file = File . createTempFile ( prefix , suffix ) ; // Copy the library code into the local file try ( FileOutputStream outs = new FileOutputStream ( file ) ) { try ( InputStream ins = filename . openStream ( ) ) { final byte [ ] buffer = new byte [ BUFFER_SIZE ] ; int lu ; while ( ( lu = ins . read ( buffer ) ) > 0 ) { outs . write ( buffer , 0 , lu ) ; } } } // Load the library from the local file load ( file ) ; // Delete local file file . deleteOnExit ( ) ; } }
Loads a code file with the specified filename from the local file system as a dynamic library . The filename argument must be a complete path name .