diff options
author | Gary Gregory <gardgregory@gmail.com> | 2022-07-28 07:57:17 -0400 |
---|---|---|
committer | Gary Gregory <gardgregory@gmail.com> | 2022-07-28 07:57:17 -0400 |
commit | 73a3f2d08701ba8d222ff2f9e023428c46457311 (patch) | |
tree | 0374a2b88ca5f6d1b4b8bd17b87b6bfa76bd44eb /src/main/java/org | |
parent | c5e8b7b4f8fbd03e3e96098030409fc9edb56bde (diff) | |
download | apache-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.java | 10 |
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. |