private static String bundled(String library) throws IOException
    {
        InputStream in = null;
        OutputStream out = null;
        try
        {
            String libraryName = File.separator + libraryPath(library);
            in = Loader.class.getResourceAsStream(libraryName);
            File tmpDir = new File(System.getProperty("java.io.tmpdir"));
            String s = System.mapLibraryName(library);
            int idx = s.lastIndexOf('.');
            File file = null;
            if (idx >= 0) {
                file = File.createTempFile(s.substring(0, idx), s.substring(idx), tmpDir);
            } else {
                file = File.createTempFile(s, null, tmpDir);
            }
            file.deleteOnExit();
            out = new FileOutputStream(file);
            int cnt;
            byte buf[] = new byte[4096];
            while ((cnt = in.read(buf)) >= 1)
            {
                out.write(buf, 0, cnt);
            }
            return file.getAbsolutePath();
        }
        finally
        {
            try
            {
                in.close();
            }
            catch (Exception ignore)
            {
            }
            try
            {
                out.close();
            }
            catch (Exception ignore)
            {
            }
        }
    }