import java.io.File;
public class FileDemo {
public static void main(String[] args) {
File file = new File("G:\\AAA");
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());
}
}
|