
正文
java后台打开浏览器代码
提示:扫一扫查出行【扫一扫了解最新限行尾号】
复制提示
import java.awt.Desktop;
import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;public class aa{
public static void main(String[] args) throws IOException, URISyntaxException {
String webSite = "http://www.baidu.com";
OpenBroswer(webSite);
} public static void OpenBroswer(String webSite) throws URISyntaxException,
IOException {
Desktop desktop = Desktop.getDesktop();
if (Desktop.isDesktopSupported() && desktop.isSupported(Desktop.Action.BROWSE)) {
URI uri = new URI(webSite);
desktop.browse(uri);
}
}
}






