public static void main(String args[]){
try {
//不是在Java程序中执行而是在操作系统中执行
// Runtime.getRuntime().exec("cmd /c start http://lqi.iteye.com/");
Runtime.getRuntime().exec("explorer \"http://lqi.iteye.com\"");
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
本文介绍如何在Java程序中利用Runtime.exec()方法执行操作系统命令,实现访问HTTP资源的功能。通过实例演示了如何使用Runtime类的exec方法调用CMD和explorer来打开特定网页,并详细解释了捕获并处理可能发生的IOException。
1638

被折叠的 条评论
为什么被折叠?



