能遇到只读文件,无法删除.使用 file 方法删除

This commit is contained in:
bwcx_jzy 2021-08-02 10:11:24 +08:00
parent 1f070fc5e4
commit 7539cfea11

View File

@ -712,12 +712,8 @@ public class FileUtil extends PathUtil {
try {
Files.delete(file.toPath());
} catch (AccessDeniedException access) {
// 可能遇到只读文件无法删除先尝试处理权限
try {
file.setWritable(true);
} catch (Exception exception) {
throw new IORuntimeException(access);
}
// 可能遇到只读文件无法删除.使用 file 方法删除
return file.delete();
} catch (IOException e) {
throw new IORuntimeException(e);
}