Gernot Neppert mcnepp02 at
Tue Jun 25 23:17:54 PDT 2013

2013/6/25 Remi Forax <forax at>

> To summarize, either the user create explicitly a Reader (a resource) and
> in that case it has to use a TWR,
> or it doesn't want to create the resource explicitly (Files.lines is a
> good example) and
> the resource is created and closed when doing the terminal operation.

...or take the middle ground and make the resource allocation function
explicit in a "ResourceStream" interface, (yielding an AutoCloseable
Stream), as I proposed yesterday.
Wouldn't that have the advantages of both of the above approaches?

try(CloseableStream<String> s =
Files.lines(path).filter(getPredicate()).open()) {
    ... // do something with s.

More information about the lambda-libs-spec-observers mailing list