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

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();
}
}
}
posted on 2015-09-08 11:55  XZhe  阅读(422)  评论(0编辑  收藏  举报