class ExecCmd { public static void main(String args[]) { Runtime run = Runtime.getRuntime(); Process process = null; try { process = run.exec("notepad"); // 执行cmd命令 process.waitFor(); } catch (Exception e) { System.out.println("Error executing notepad."); } System.out.println("Notepad returned " + process.exitValue()); } }
原创文章,作者:Maggie-Hunter,如若转载,请注明出处:https://blog.ytso.com/10158.html