nd4j-buffer/src/main/java/org/nd4j/linalg/api/buffer/util/LibUtils.java
public static void loadTempBinaryFile(Class<?> libName) throws Exception {
        String os = getOsName();
        String arch = getArchName();
        String resourceFolder = os + "-" + arch;
        String libPrefix = createLibPrefix();
        String libExtension = createLibExtension();
        StringBuilder sb = new StringBuilder().append(libName.getPackage().getName().replace(".", "/") + "/")
                        .append(resourceFolder).append("/").append(libPrefix)
                        .append("jni" + libName.getSimpleName() + ".").append(libExtension);
        String resourceName = sb.toString();
        ClassPathResource resource = new ClassPathResource(resourceName);
        InputStream inputStream = resource.getInputStream();
        if (inputStream == null) {
            throw new NullPointerException("No resource found with name '" + resourceName + "'");
        }

        String fullName = libPrefix + "jni" + libName.getSimpleName() + "." + libExtension;
        File tempFile = new File(System.getProperty("java.io.tmpdir"), fullName);
        tempFile.deleteOnExit();
        OutputStream outputStream = null;
        try {
            outputStream = new FileOutputStream(tempFile);
            byte[] buffer = new byte[8192];
            while (true) {
                int read = inputStream.read(buffer);
                if (read < 0) {
                    break;
                }
                outputStream.write(buffer, 0, read);
            }
            outputStream.flush();
            outputStream.close();
            outputStream = null;

            System.load(tempFile.getAbsolutePath());
        } finally {
            if (outputStream != null) {
                outputStream.close();
            }
        }


    }
public static void loadTempBinaryFile(Class<?> libName) throws Exception {
        String os = getOsName();
        String arch = getArchName();
        String resourceFolder = os + "-" + arch;
        String libPrefix = createLibPrefix();
        String libExtension = createLibExtension();
        StringBuilder sb = new StringBuilder().append(libName.getPackage().getName().replace(".", "/") + "/")
                        .append(resourceFolder).append("/").append(libPrefix)
                        .append("jni" + libName.getSimpleName() + ".").append(libExtension);
        String resourceName = sb.toString();
        ClassPathResource resource = new ClassPathResource(resourceName);
        InputStream inputStream = resource.getInputStream();
        if (inputStream == null) {
            throw new NullPointerException("No resource found with name '" + resourceName + "'");
        }

        String fullName = libPrefix + "jni" + libName.getSimpleName() + "." + libExtension;
        File tempFile = new File(System.getProperty("java.io.tmpdir"), fullName);
        tempFile.deleteOnExit();
        OutputStream outputStream = null;
        try {
            outputStream = new FileOutputStream(tempFile);
            byte[] buffer = new byte[8192];
            while (true) {
                int read = inputStream.read(buffer);
                if (read < 0) {
                    break;
                }
                outputStream.write(buffer, 0, read);
            }
            outputStream.flush();
            outputStream.close();
            outputStream = null;

            System.load(tempFile.getAbsolutePath());
        } finally {
            if (outputStream != null) {
                outputStream.close();
            }
        }


    }
public static void loadTempBinaryFile ( Class < ? > libName ) throws Exception { String os = getOsName ( ) ; String arch = getArchName ( ) ; String resourceFolder = os + "-" + arch ; String libPrefix = createLibPrefix ( ) ; String libExtension = createLibExtension ( ) ; StringBuilder sb = new StringBuilder ( ) . append ( libName . getPackage ( ) . getName ( ) . replace ( "." , "/" ) + "/" ) . append ( resourceFolder ) . append ( "/" ) . append ( libPrefix ) . append ( "jni" + libName . getSimpleName ( ) + "." ) . append ( libExtension ) ; String resourceName = sb . toString ( ) ; ClassPathResource resource = new ClassPathResource ( resourceName ) ; InputStream inputStream = resource . getInputStream ( ) ; if ( inputStream == null ) { throw new NullPointerException ( "No resource found with name '" + resourceName + "'" ) ; } String fullName = libPrefix + "jni" + libName . getSimpleName ( ) + "." + libExtension ; File tempFile = new File ( System . getProperty ( "java.io.tmpdir" ) , fullName ) ; tempFile . deleteOnExit ( ) ; OutputStream outputStream = null ; try { outputStream = new FileOutputStream ( tempFile ) ; byte [ ] buffer = new byte [ 8192 ] ; while ( true ) { int read = inputStream . read ( buffer ) ; if ( read < 0 ) { break ; } outputStream . write ( buffer , 0 , read ) ; } outputStream . flush ( ) ; outputStream . close ( ) ; outputStream = null ; System . load ( tempFile . getAbsolutePath ( ) ) ; } finally { if ( outputStream != null ) { outputStream . close ( ) ; } } }
Load the library with the given name from a resource.
The extension for the current OS will be appended.

@param libName The library name
@throws Throwable If the library could not be loaded
Load the library with the given name from a resource . The extension for the current OS will be appended .