Stream instead of loop
MODIFY
src/main/java/org/apache/commons/io/input/BOMInputStream.java
src/main/java/org/apache/commons/io/input/BOMInputStream.java
@@ -172,12 +172,7 @@ public BOMInputStream(final InputStream delegate, final ByteOrderMark... boms) {
* @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);
}
/**

Stream instead of loop