File
private static void close(Closeable obj) throws IOException {
if (obj != null) {
obj.close();
}
}倘若需要刪除時,檔案卻被莫名咬住,需要強行刪除
public boolean forceDelete(File file) {
boolean result = file.delete();
int tryCount = 0;
while (!result && tryCount++ < 10) {
System.gc(); //回收資源
result = file.delete();
}
return result;
}Last updated