最新消息: USBMI致力于为网友们分享Windows、安卓、IOS等主流手机系统相关的资讯以及评测、同时提供相关教程、应用、软件下载等服务。

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

业界 admin 5浏览 0评论
package com.test;

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

public class TestHtml {

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

 

package com.test;

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

public class TestHtml {

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

 

发布评论

评论列表 (0)

  1. 暂无评论