mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-05-09 23:51:34 +08:00
能遇到只读文件,无法删除.使用 file 方法删除
This commit is contained in:
parent
1f070fc5e4
commit
7539cfea11
@ -712,12 +712,8 @@ public class FileUtil extends PathUtil {
|
|||||||
try {
|
try {
|
||||||
Files.delete(file.toPath());
|
Files.delete(file.toPath());
|
||||||
} catch (AccessDeniedException access) {
|
} catch (AccessDeniedException access) {
|
||||||
// 可能遇到只读文件,无法删除,先尝试处理权限
|
// 可能遇到只读文件,无法删除.使用 file 方法删除
|
||||||
try {
|
return file.delete();
|
||||||
file.setWritable(true);
|
|
||||||
} catch (Exception exception) {
|
|
||||||
throw new IORuntimeException(access);
|
|
||||||
}
|
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
throw new IORuntimeException(e);
|
throw new IORuntimeException(e);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user