Runtime run = Runtime.getRuntime() ;
try
{
run.exec("explorer http://sport.sina.com.cn");
//把http://sport.sina.com.cn换成你要的url就行.
} catch (IOException ex)
{
ex.printStackTrace();
}
这个是Windows系统上的做法,换其他系统就不行了,但是只要搞清楚本质就行了。
本质就是开启一个浏览器进程,然后把网址传给它,就能显示网址了,一般采用的是系统的默认浏览器,其他系统的话一般要搞清楚默认浏览器是什么,做好系统的判断,根据不同的系统打开不同的浏览器,才能做到通用性。
Runtime run = Runtime.getRuntime() ;
try
{
run.exec("explorer http://sport.sina.com.cn");
//把http://sport.sina.com.cn换成你要的url就行.
} catch (IOException ex)
{
ex.printStackTrace();
}