From 7bed31e13f4df8a4d65ee898d1c0839e3f09215a Mon Sep 17 00:00:00 2001 From: Looly Date: Fri, 24 Mar 2023 00:06:32 +0800 Subject: [PATCH] =?UTF-8?q?FileUtil=E5=A2=9E=E5=8A=A0readLines=E9=87=8D?= =?UTF-8?q?=E8=BD=BD=EF=BC=8C=E6=94=AF=E6=8C=81filter?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 1 + hutool-core/src/main/java/cn/hutool/core/io/FileUtil.java | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c0f418fe8..c5fca4b4c 100755 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ * 【extra 】 优化SpringUtil在非Spring环境下的异常(issue#2835@Github) * 【core 】 StrUtil增加commonPrefix和commonSuffix方法(pr#3007@Github) * 【core 】 NumberUtil增加重载parseXXX方法, 解析失败返回默认值(pr#3007@Github) +* 【core 】 FileUtil增加readLines重载,支持filter(pr#3006@Github) ### 🐞Bug修复 * 【crypto】 修复NoSuchMethodError未捕获问题(issue#2966@Github) diff --git a/hutool-core/src/main/java/cn/hutool/core/io/FileUtil.java b/hutool-core/src/main/java/cn/hutool/core/io/FileUtil.java index bd8df24b1..333a34358 100755 --- a/hutool-core/src/main/java/cn/hutool/core/io/FileUtil.java +++ b/hutool-core/src/main/java/cn/hutool/core/io/FileUtil.java @@ -2418,7 +2418,7 @@ public class FileUtil extends PathUtil { public static List readLines(File file, Charset charset, Predicate filter) throws IORuntimeException { final List result = new ArrayList<>(); readLines(file, charset, (LineHandler) line -> { - if (Boolean.TRUE.equals(filter.test(line))) { + if (filter.test(line)) { result.add(line); } });