public class Test {
public static void main(String[] args) {
File f = new File("F:\\bwie");
deleteAll(f);
}
public static void deleteAll(File f){
if(f.isDirectory()){
File arrFiles[] = f.listFiles();
for (File file : arrFiles) {
if(file.isDirectory()){
deleteAll(file);
}else{
file.delete();
}
file.delete(); //删除目录下的所有文件后,再删除该文件目录
}
}
}
}
public static void main(String[] args) {
File f = new File("F:\\bwie");
deleteAll(f);
}
public static void deleteAll(File f){
if(f.isDirectory()){
File arrFiles[] = f.listFiles();
for (File file : arrFiles) {
if(file.isDirectory()){
deleteAll(file);
}else{
file.delete();
}
file.delete(); //删除目录下的所有文件后,再删除该文件目录
}
}
}
}