java 程序打开网页

来源:互联网 发布:mac桌面文件复制到u盘 编辑:程序博客网 时间:2024/05/20 15:38


时间一久,就记不住公司企业邮箱的URL  和 Jira  地址,

老大建议安装一客户端,为了给我的电脑节省空间,决定不安装这2个软件,可是有时候忘了地址怎么办?

早上突然想到:java 程序应该能直接打开网页吧!

于是开始行动,百度一下:

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

网上的大牛们是这么写的

汗……,就这么一句话?

于是查了一下:java  rundll32 url.dll,fileProtocalHandler,

长了些许见识,其中有2个网址感觉受益:

http://www.cnblogs.com/itime/archive/2012/02/11/2347178.html
http://blog.csdn.net/ybygjy/article/details/6079363

于是,将我的程序编译好,在桌面做成可执行文件,这下方便多了

嘻嘻,有了收获,特别开心……

写下自己喜欢的英文小诗:

try try try,and never say die,things will com right to you,by and by!



原创粉丝点击