mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-04-19 03:01:48 +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 】 增加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计算问题
|
||||||
|
@ -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()) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user