/**
* @note 删除目录下的所有文件
* @param path
* @return
*/
public static boolean delAllFile(String path){
boolean flag = false;
if(StringUtil.isBlank(path)){
return false;
}
File file = new File(path);
if(!file.exists())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();
flag=true;
}
if (temp.isDirectory()) {
delAllFile(path + File.separator + tempList[i]);//先删除文件夹里面的文件
flag = true;
}
}
return flag;
}
文章地址https://www.yii666.com/article/756062.html 网址:yii666.com文章来源地址:https://www.yii666.com/article/756062.html