Discussion: easier Stream closing
Stephen Colebourne
scolebourne at joda.org
Sun Sep 26 16:02:34 UTC 2021
On Sun, 26 Sept 2021 at 10:29, Tagir Valeev <amaembo at gmail.com> wrote:
> List<Path> list =
> Files.list(Path.of("/etc")).map(Path::getFileName).consumeAndClose(Stream::toList);
>
> What do you think?
I fully support this. We have our own utility to do this kind of
thing, as bugs with `Files` are common:
https://github.com/OpenGamma/Strata/blob/main/modules/collect/src/main/java/com/opengamma/strata/collect/io/SafeFiles.java
Stephen
More information about the core-libs-dev
mailing list