1 /**
2 * @note 删除目录下的所有文件
3 * @param path
4 * @return
5 */
6 public static boolean delAllFile(String path){
7 boolean flag = false;
8 if(StringUtil.isBlank(path)){
9 return false;
10 }
11 File file = new File(path);
12 if(!file.exists())return flag;
13 String[] tempList= file.list();
14 File temp = null;
15 for (int i = 0; i < tempList.length; i++) {
16 if (path.endsWith(File.separator)) {
17 temp = new File(path + tempList[i]);
18 } else {
19 temp = new File(path + File.separator + tempList[i]);
20 }
21 if (temp.isFile()) {
22 temp.delete();
23 flag=true;
24 }
25 if (temp.isDirectory()) {
26 delAllFile(path + File.separator + tempList[i]);//先删除文件夹里面的文件
27 flag = true;
28 }
29 }
30 return flag;
31 }