/** * Converts checked exceptions to unchecked based on the {@code BiConsumer} interface. * <p> * This wraps the specified consumer returning an instance that handles checked exceptions. * If a checked exception is thrown it is converted to an {@link UncheckedIOException} * or {@link RuntimeException} as appropriate. * * @param <T> the first type of the consumer * @param <U> the second type of the consumer * @param consumer the consumer to be decorated * @return the consumer instance that handles checked exceptions */ public static <T, U> BiConsumer<T, U> biConsumer(CheckedBiConsumer<T, U> consumer) { return (t, u) -> { try { consumer.accept(t, u); } catch (Throwable ex) { throw propagate(ex); } }; }