通过java后端获取的网址打开浏览器

protected void browser(final String url) {
        try {
            final String osName = System.getProperty("os.name");
            if (osName.startsWith("Windows")) {
                Runtime.getRuntime().exec("rundll32 url.dll,FileProtocolHandler  " + url);
            } else if (osName.startsWith("Mac OS")) {
                final Class fileMgr = Class.forName("com.apple.eio.FileManager");
                final Method openURL = fileMgr.getDeclaredMethod("openURL", new Class[] { String.class });
                openURL.invoke(null, new Object[] { url });
            }
        } catch (final Exception e) {
            e.printStackTrace();
        }
    }

你可能感兴趣的:(通过java后端获取的网址打开浏览器)