java 打开默认浏览器并且打开指定网页

package com.test;

import java.awt.Desktop;
import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;

public class TestHtml {

	public static void main(String[] args) {
		String str = "cmd /c start iexplore http://www.baidu.com";
		try {
			Runtime.getRuntime().exec(str);
		} catch (IOException e) {
			e.printStackTrace();
		}
		try {
			URI uri = new URI("http://www.baidu.com");
			Desktop.getDesktop().browse(uri);
		} catch (URISyntaxException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
}

猜你喜欢

转载自blog.csdn.net/weixin_42749765/article/details/81560146
今日推荐