调用系统命令实现删除文件的操作

public class DSOOperation {
public static void main(String[] args) {
Runtime run=Runtime.getRuntime();
try {
//cmd /c 下面这句就是删除文件
run.exec("cmd /c del D:\tt.txt");

//控制台显示信息
Process p=run.exec("cmd /c dir src");
InputStream is=p.getInputStream();
BufferedReader read=new BufferedReader(new InputStreamReader(is));
while(true){
String s=read.readLine();
if(s==null)break;
System.err.println(s);
}
} catch (IOException e) {
e.printStackTrace();
}
}
}
原文地址:https://www.cnblogs.com/GodZhe/p/4791184.html