java窗口中打开uri

来源:互联网 发布:高保真分色软件 编辑:程序博客网 时间:2024/05/02 10:49
 public static void openFile(File file) throws IOException {        if (Desktop.isDesktopSupported()) {            Desktop desktop = Desktop.getDesktop();            desktop.open(file);        }    }       public static boolean runBroswer(String webSite) {        try {            Desktop desktop = Desktop.getDesktop();            if (desktop.isDesktopSupported() && desktop.isSupported(Desktop.Action.BROWSE)) {                URI uri = new URI(webSite);                desktop.browse(uri);            }        } catch (IOException ex) {            ex.printStackTrace();        } catch (URISyntaxException ex) {            ex.printStackTrace();        }        return true;    }       public static boolean runBroswer(URI uri) {        try {            Desktop desktop = Desktop.getDesktop();            if (desktop.isDesktopSupported() && desktop.isSupported(Desktop.Action.BROWSE)) {                desktop.browse(uri);            }        } catch (IOException ex) {            ex.printStackTrace();        }        return true;    }