io-functions
The io-functions
library provides functional interfaces for I/O operations. These are basically copies of the functional interfaces in java.util.functions except their methods can throw IOExceptions.
Each of these interfaces also contains static methods unchecked
and checked
to convert them into their matching JSE equivalents. For example, to delete all files in a directory that match a filter, you can use IOConsumer.unchecked:
try (DirectoryStream<Path> stream = Files.newDirectoryStream(dir, filter)) {
stream.forEach(unchecked(Files::delete));
} catch (UncheckedIOException e) {
throw e.getCause();
}