**
file.delete()删除文件失败
**
问题原因:映射占用
解决方法:执行10次垃圾回收后删除,目前可以解决这个问题
public static boolean deleteFile(String path){
boolean result = false;
File file=new File(path);
if(file.isFile() && file.exists()){
int tryCount = 0;
while(!result && tryCount++ <10)
{
System.gc();
result = file.delete();
}
}
return result;
}
个人记录
原文地址 : https://blog.csdn.net/qq_30353203/article/details/97803120