java打开网页的2种方式

来源:互联网 发布:叮叮软件官网 编辑:程序博客网 时间:2024/05/17 07:59
import java.net.URISyntaxException;public class test {public static void main(String[] args) {String cmdStr = "cmd /c start iexplore http://www.baidu.com/";try {Runtime.getRuntime().exec(cmdStr);} catch (IOException e) {e.printStackTrace();} try {URI uri=new URI("http://www.baidu.com/");Desktop.getDesktop().browse(uri); } catch (IOException e) {e.printStackTrace();} catch (URISyntaxException e) {e.printStackTrace();}}}