java如何调用本地的浏览器

1.调用本地的浏览器 
import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;

public class UseBrowser {
	public static void main(String[] args) {
		URL url = null;
		try {
			url = new URL("http://www.baidu.com");
		} catch (MalformedURLException e1) {
			// TODO Auto-generated catch block
			e1.printStackTrace();
		}
		try {
			Runtime.getRuntime().exec(
					"rundll32 url.dll,FileProtocolHandler "
							+ url);
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
}

2.掉用windows上的记事本

import java.io.IOException;

public class UseNotepad {
	public static void main(String[] args) {
		
		try {
			Runtime.getRuntime().exec("notepad");
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
}


你可能感兴趣的:(java)