package IO;
import java.io.File;
public class 删除带内容的文件 {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
File f=new File("c:\\演示");
removedir(f);
}
public static void removedir(File f1){
File[] f2=f1.listFiles();
for (int i = 0; i < f2.length; i++) {
if (f2[i].isDirectory()) {
removedir(f2[i]);
}else {
System.out.println(f2[i].delete());
}
System.out.println(f2[i].toString()+"FileDelete"+f2[i].delete());
}
}
}
为什么删除不了根目录? |
|