Add IOBiConsumer.
MODIFY
src/changes/changes.xml
src/changes/changes.xml
@@ -284,6 +284,9 @@ The <action> type attribute can be add,update,fix,remove.
<action dev="ggregory" type="add" due-to="Gary Gregory">
Add IOExceptionList.checkEmpty(List, Object).
</action>
+ <action dev="ggregory" type="add" due-to="Gary Gregory">
+ Add IOBiConsumer.
+ </action>
<!-- UPDATE -->
<action dev="ggregory" type="add" due-to="Gary Gregory">
Update FileEntry to use FileTime instead of long for file time stamps.

ADD
src/main/java/org/apache/commons/io/function/IOBiConsumer.java
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.commons.io.function;
+
+import java.io.IOException;
+import java.util.Objects;
+import java.util.function.BiConsumer;
+
+/**
+ * Like {@link BiConsumer} but throws {@link IOException}.
+ *
+ * @param <T> the type of the first argument to the operation
+ * @param <U> the type of the second argument to the operation
+ *
+ * @see BiConsumer
+ * @since 1.8
+ */
+@FunctionalInterface
+public interface IOBiConsumer<T, U> {
+
+ /**
+ * Performs this operation on the given arguments.
+ *
+ * @param t the first input argument
+ * @param u the second input argument
+ * @throws IOException if an I/O error occurs.
+ */
+ void accept(T t, U u) throws IOException;
+
+ /**
+ * Returns a composed {@code BiConsumer} that performs, in sequence, this operation followed by the {@code after}
+ * operation. If performing either operation throws an exception, it is relayed to the caller of the composed operation.
+ * If performing this operation throws an exception, the {@code after} operation will not be performed.
+ *
+ * @param after the operation to perform after this operation
+ * @return a composed {@code BiConsumer} that performs in sequence this operation followed by the {@code after}
+ * operation
+ * @throws NullPointerException if {@code after} is null
+ */
+ default IOBiConsumer<T, U> andThen(IOBiConsumer<? super T, ? super U> after) {
+ Objects.requireNonNull(after);
+
+ return (l, r) -> {
+ accept(l, r);
+ after.accept(l, r);
+ };
+ }
+}

ADD
src/test/java/org/apache/commons/io/function/IOBiConsumerTest.java
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.commons.io.function;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+import java.io.IOException;
+import java.util.concurrent.atomic.AtomicReference;
+
+import org.junit.jupiter.api.Test;
+
+/**
+ * Tests {@link IOBiConsumer}.
+ */
+public class IOBiConsumerTest {
+
+ @Test
+ public void testAccept() throws IOException {
+ final AtomicReference<String> ref = new AtomicReference<>();
+ final IOBiConsumer<String, Integer> biConsumer = (s, i) -> ref.set(s + i);
+ biConsumer.accept("A", 1);
+ assertEquals("A1", ref.get());
+ }
+
+ @Test
+ public void testAndThen() throws IOException {
+ final AtomicReference<String> ref = new AtomicReference<>();
+ final IOBiConsumer<String, Integer> biConsumer1 = (s, i) -> ref.set(s + i);
+ final IOBiConsumer<String, Integer> biConsumer2 = (s, i) -> ref.set(ref.get() + i + s);
+ biConsumer1.andThen(biConsumer2).accept("B", 2);
+ assertEquals("B22B", ref.get());
+ }
+}

Add IOBiConsumer.