This commit is contained in:
2023-07-17 14:30:53 +08:00
parent eb69602e21
commit 2587110cc2
8 changed files with 53 additions and 75 deletions

View File

@@ -49,4 +49,33 @@ public class ZipUtil {
File zipFileFromImages = ZipUtil.createZipFileFromImages(list);
System.out.println(zipFileFromImages);
}
/**
* 删除指定文件夹下的所有文件
* @param path
* @return
*/
public static boolean delAllFile(String path) {
boolean flag = false;
File file = new File(path);
if (!file.exists()) {
return flag;
}
if (!file.isDirectory()) {
return flag;
}
String[] tempList = file.list();
File temp = null;
for (int i = 0; i < tempList.length; i++) {
if (path.endsWith(File.separator)) {
temp = new File(path + tempList[i]);
} else {
temp = new File(path + File.separator + tempList[i]);
}
if (temp.isFile()) {
temp.delete();
}
}
return flag;
}
}