调用系统命令删除文件




windows:

Runtime runtime = Runtime.getRuntime(); 
String[] args = new String[] {"cmd.exe", "/c", "rd c:\\xxx /q /s"};
Process proc = runtime.exec(args);

linux:

Runtime runtime = Runtime.getRuntime(); 
String[] args = new String[] {"sh", "-c", "rm -f -r /usr/dir"};
Process proc = runtime.exec(args);



你可能感兴趣的:(Java)