在社区看到java调用本地dos命令的代码,特贴出来
String command = "ipconfig";
Runtime run = Runtime.getRuntime();
Process pro = run.exec(command);
BufferedReader read = new BufferedReader(new InputStreamReader(pro.getInputStream(), "GBK"));
StringBuilder sb = new StringBuilder();
String con = "";
while(null != (con = read.readLine())) {
sb.append(con + "\r\n");
}
System.out.println(sb.toString());
执行其他命令,就把command修改了就行,不知道是不是你想要的。