请问在java中执行dos命令 怎么些?

来源:百度知道 编辑:UC知道 时间:2024/05/10 06:14:55
比如我要打开一个记事本

嘿嘿..

Runtime rt=Runtime.getRuntime();
String cmd="c:\\windows\\system32\\notepad.exe";
try{
rt.exec(cmd);
}
catch(IOException e){
e.printStackTrace();
}

public class Test{
public static void main(String args[]){
Runtime rt=Runtime.getRuntime();
String cmd="c:\\windows\\system32\\notepad.exe";
try{
rt.exec(cmd);
}
catch(Exception e){
e.printStackTrace();
}
}
}