aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/org
diff options
context:
space:
mode:
authorGary Gregory <gardgregory@gmail.com>2022-07-28 07:57:17 -0400
committerGary Gregory <gardgregory@gmail.com>2022-07-28 07:57:17 -0400
commit73a3f2d08701ba8d222ff2f9e023428c46457311 (patch)
tree0374a2b88ca5f6d1b4b8bd17b87b6bfa76bd44eb /src/main/java/org
parentc5e8b7b4f8fbd03e3e96098030409fc9edb56bde (diff)
downloadapache-commons-io-73a3f2d08701ba8d222ff2f9e023428c46457311.tar.gz
Add IORunnable#asRunnable()
Diffstat (limited to 'src/main/java/org')
-rw-r--r--src/main/java/org/apache/commons/io/function/IORunnable.java10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/main/java/org/apache/commons/io/function/IORunnable.java b/src/main/java/org/apache/commons/io/function/IORunnable.java
index 01403ef7..8afa2979 100644
--- a/src/main/java/org/apache/commons/io/function/IORunnable.java
+++ b/src/main/java/org/apache/commons/io/function/IORunnable.java
@@ -18,6 +18,7 @@
package org.apache.commons.io.function;
import java.io.IOException;
+import java.io.UncheckedIOException;
/**
* Like {@link Runnable} but throws {@link IOException}.
@@ -28,6 +29,15 @@ import java.io.IOException;
public interface IORunnable {
/**
+ * Creates a {@link Runnable} for this instance that throws {@link UncheckedIOException} instead of {@link IOException}.
+ *
+ * @return an unchecked Predicate.
+ */
+ default Runnable asRunnable() {
+ return () -> Uncheck.run(this);
+ }
+
+ /**
* Like {@link Runnable#run()} but throws {@link IOException}.
*
* @throws IOException if an I/O error occurs.