public class DeletFileDemo {
public static void main(String[] args) {
String str = "F:\\";
delete(str);
}
public static void delete(String str) {
File file = new File(str);
File[] files = file.listFiles();
for (File f : files) {
if (!f.delete()) {
File file1 = new File(str, f.getName());
DeletFileDemo.delete(file1.getAbsolutePath());
}
f.delete();
}
file.delete();
}
} |