You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by gg...@apache.org on 2022/06/15 14:11:48 UTC
[commons-io] 03/04: Stream instead of loop
This is an automated email from the ASF dual-hosted git repository.
ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-io.git
commit 7ecddab7b73b932efc7c30bdc44ff7c432ebac17
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Wed Jun 15 10:11:23 2022 -0400
Stream instead of loop
---
src/main/java/org/apache/commons/io/input/BOMInputStream.java | 7 +------
1 file changed, 1 insertion(+), 6 deletions(-)
diff --git a/src/main/java/org/apache/commons/io/input/BOMInputStream.java b/src/main/java/org/apache/commons/io/input/BOMInputStream.java
index 85043d53..ec7f8207 100644
--- a/src/main/java/org/apache/commons/io/input/BOMInputStream.java
+++ b/src/main/java/org/apache/commons/io/input/BOMInputStream.java
@@ -172,12 +172,7 @@ public class BOMInputStream extends ProxyInputStream {
* @return The matched BOM or null if none matched
*/
private ByteOrderMark find() {
- for (final ByteOrderMark bom : boms) {
- if (matches(bom)) {
- return bom;
- }
- }
- return null;
+ return boms.stream().filter(this::matches).findFirst().orElse(null);
}
/**