change size logic

This commit is contained in:
Looly 2020-04-23 11:08:44 +08:00
parent bd4bd2d4c9
commit 3f97a1e495
2 changed files with 5 additions and 5 deletions

View File

@ -3,12 +3,13 @@
------------------------------------------------------------------------------------------------------------- -------------------------------------------------------------------------------------------------------------
## 5.3.2 (2020-04-19) ## 5.3.2 (2020-04-23)
### 新特性 ### 新特性
* 【core 】 增加NetUtil.isOpen方法 * 【core 】 增加NetUtil.isOpen方法
* 【core 】 增加ThreadUtil.sleep和safeSleep的重载 * 【core 】 增加ThreadUtil.sleep和safeSleep的重载
* 【core 】 Sftp类增加toString方法issue#I1F2T4@Gitee * 【core 】 Sftp类增加toString方法issue#I1F2T4@Gitee
* 【core 】 修改FileUtil.size逻辑不存在的文件返回0
### Bug修复 ### Bug修复
* 【db 】 修复PageResult.isLast计算问题 * 【db 】 修复PageResult.isLast计算问题

View File

@ -589,13 +589,12 @@ public class FileUtil {
* 当给定对象为文件时直接调用 {@link File#length()}<br> * 当给定对象为文件时直接调用 {@link File#length()}<br>
* 当给定对象为目录时遍历目录下的所有文件和目录递归计算其大小求和返回 * 当给定对象为目录时遍历目录下的所有文件和目录递归计算其大小求和返回
* *
* @param file 目录或文件 * @param file 目录或文件,null或者文件不存在返回0
* @return 总大小bytes长度 * @return 总大小bytes长度
*/ */
public static long size(File file) { public static long size(File file) {
Assert.notNull(file, "file argument is null !"); if (null == file || false == file.exists()) {
if (false == file.exists()) { return 0;
throw new IllegalArgumentException(StrUtil.format("File [{}] not exist !", file.getAbsolutePath()));
} }
if (file.isDirectory()) { if (file.isDirectory()) {