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;
}
java窗口中打开uri
最新推荐文章于 2022-05-23 21:14:35 发布