mirror of
https://gitee.com/dromara/hutool.git
synced 2025-04-05 17:37:59 +08:00
change size logic
This commit is contained in:
parent
bd4bd2d4c9
commit
3f97a1e495
@ -3,12 +3,13 @@
|
||||
|
||||
-------------------------------------------------------------------------------------------------------------
|
||||
|
||||
## 5.3.2 (2020-04-19)
|
||||
## 5.3.2 (2020-04-23)
|
||||
|
||||
### 新特性
|
||||
* 【core 】 增加NetUtil.isOpen方法
|
||||
* 【core 】 增加ThreadUtil.sleep和safeSleep的重载
|
||||
* 【core 】 Sftp类增加toString方法(issue#I1F2T4@Gitee)
|
||||
* 【core 】 修改FileUtil.size逻辑,不存在的文件返回0
|
||||
|
||||
### Bug修复
|
||||
* 【db 】 修复PageResult.isLast计算问题
|
||||
|
@ -589,13 +589,12 @@ public class FileUtil {
|
||||
* 当给定对象为文件时,直接调用 {@link File#length()}<br>
|
||||
* 当给定对象为目录时,遍历目录下的所有文件和目录,递归计算其大小,求和返回
|
||||
*
|
||||
* @param file 目录或文件
|
||||
* @param file 目录或文件,null或者文件不存在返回0
|
||||
* @return 总大小,bytes长度
|
||||
*/
|
||||
public static long size(File file) {
|
||||
Assert.notNull(file, "file argument is null !");
|
||||
if (false == file.exists()) {
|
||||
throw new IllegalArgumentException(StrUtil.format("File [{}] not exist !", file.getAbsolutePath()));
|
||||
if (null == file || false == file.exists()) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (file.isDirectory()) {
|
||||
|
Loading…
Reference in New Issue
Block a user