File filePath = new File(ObjectPath);
if (!filePath.exists()) {
filePath.mkdirs();
System.out.println("目录不存在!");
} else {
if (filePath.isDirectory()) {
File[] list = filePath.listFiles();
for (int i = 0; i < list.length; i++) {
list[i].delete();
}
}
filePath.delete();
}
}
/**
* 判断某文件夹下是否存在文件,存在返回true
*
* @param ObjectPath
* @return
*/
public static boolean existFileInDirectory(String ObjectPath) {
boolean flag = false;
File filePath = new File(ObjectPath);
if (filePath.exists()) {
if (filePath.isDirectory()) {
File[] list = filePath.listFiles();
if (list != null && list.length != 0) {
flag = true;
}
}
}