import java.io.File;
import java.io.FileNotFoundException;
public class DeleteFile {
public static void main(String[] args) {
File file = new File("f:\\");
deleteFiles(file);
}
private static void deleteFiles(File file) {
File[] fileArray = file.listFiles();
if (fileArray != null) {
for (File f : fileArray) {
if (f.isDirectory()) {
deleteFiles(f);
} else {
System.out.println(f.getName() + "***" + f.delete());
}
}
}
System.out.println(file.getName() + "***" + file.delete());
}
}
|
|