package com.clear.test;
import java.io.File;
public class DeleteFile {
public static void deleteFile(File file) {
if (file.exists()) {
if (file.isFile()) {
file.delete();
} else if (file.isDirectory()) {
File files[] = file.listFiles();
for (int i = 0; i < files.length; i++) {
deleteFile(files[i]);
}
}
file.delete();
} else {
System.out.println("所删除的文件不存在!" + '\n');
}
}
public static void createFile(File file) {
file.mkdir();
}
}
阅读(1424) | 评论(0) | 转发(0) |