https://github.com/robtimus/io-functions
A collection of functional interfaces for I/O operations
https://github.com/robtimus/io-functions
functions java
Last synced: 2 months ago
JSON representation
A collection of functional interfaces for I/O operations
- Host: GitHub
- URL: https://github.com/robtimus/io-functions
- Owner: robtimus
- License: apache-2.0
- Created: 2017-05-14T14:31:51.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2024-01-20T12:49:37.000Z (over 1 year ago)
- Last Synced: 2025-01-18T01:45:21.323Z (4 months ago)
- Topics: functions, java
- Language: Java
- Homepage: https://robtimus.github.io/io-functions/
- Size: 557 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# io-functions
[](https://search.maven.org/artifact/com.github.robtimus/io-functions)
[](https://github.com/robtimus/io-functions/actions/workflows/build.yml)
[](https://sonarcloud.io/summary/overall?id=com.github.robtimus%3Aio-functions)
[](https://sonarcloud.io/summary/overall?id=com.github.robtimus%3Aio-functions)
[](https://snyk.io/test/github/robtimus/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](https://docs.oracle.com/javase/8/docs/api/java/util/function/package-summary.html) except their methods can throw [IOExceptions](https://docs.oracle.com/javase/8/docs/api/java/io/IOException.html).
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](https://robtimus.github.io/io-functions/apidocs/com/github/robtimus/io/function/IOConsumer.html#unchecked-com.github.robtimus.io.function.IOConsumer-):
try (DirectoryStream stream = Files.newDirectoryStream(dir, filter)) {
stream.forEach(unchecked(Files::delete));
} catch (UncheckedIOException e) {
throw e.getCause();
}