mirror of
https://gitee.com/dromara/hutool.git
synced 2025-04-05 17:37:59 +08:00
fix FileUtil.remove bug
This commit is contained in:
parent
74ba64c0c0
commit
368a5e4d1c
@ -10,6 +10,7 @@
|
||||
* 【core 】 增加ThreadUtil.sleep和safeSleep的重载
|
||||
* 【core 】 Sftp类增加toString方法(issue#I1F2T4@Gitee)
|
||||
* 【core 】 修改FileUtil.size逻辑,不存在的文件返回0
|
||||
* 【extra 】 Sftp.ls遇到文件不存在返回空集合,而非抛异常(issue#844@Github)
|
||||
|
||||
### Bug修复
|
||||
* 【db 】 修复PageResult.isLast计算问题
|
||||
@ -17,6 +18,7 @@
|
||||
* 【db 】 修复Page.addOrder无效问题(issue#I1F9MZ@Gitee)
|
||||
* 【json 】 修复JSONConvert转换日期空指针问题(issue#I1F8M2@Gitee)
|
||||
* 【core 】 修复XML中带注释Xpath解析导致空指针问题(issue#I1F2WI@Gitee)
|
||||
* 【core 】 修复FileUtil.rename原文件无扩展名多点的问题(issue#839@Github)
|
||||
|
||||
-------------------------------------------------------------------------------------------------------------
|
||||
## 5.3.1 (2020-04-17)
|
||||
|
@ -1175,7 +1175,10 @@ public class FileUtil {
|
||||
*/
|
||||
public static File rename(File file, String newName, boolean isRetainExt, boolean isOverride) {
|
||||
if (isRetainExt) {
|
||||
newName = newName.concat(".").concat(FileUtil.extName(file));
|
||||
final String extName = FileUtil.extName(file);
|
||||
if(StrUtil.isNotBlank(extName)){
|
||||
newName = newName.concat(".").concat(extName);
|
||||
}
|
||||
}
|
||||
final Path path = file.toPath();
|
||||
final CopyOption[] options = isOverride ? new CopyOption[]{StandardCopyOption.REPLACE_EXISTING} : new CopyOption[]{};
|
||||
|
@ -238,7 +238,10 @@ public class Sftp extends AbstractFtp {
|
||||
return LsEntrySelector.CONTINUE;
|
||||
});
|
||||
} catch (SftpException e) {
|
||||
throw new JschRuntimeException(e);
|
||||
if(false == StrUtil.startWithIgnoreCase(e.getMessage(), "No such file")){
|
||||
throw new JschRuntimeException(e);
|
||||
}
|
||||
// 文件不存在忽略
|
||||
}
|
||||
return fileNames;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user