Point lambdafications in java.io

David Holmes david.holmes at oracle.com
Fri Jun 21 03:03:05 PDT 2013

I don't get this at all. I get you can have Streams underpinned by I/O 
streams and that I/O streams have associated resources and need closing. 
But that doesn't imply all Streams have underlying resources and/or need 

Why should an attribute specific to one particular kind of Stream 
propagate up into Stream itself yet be meaningless for many kinds of 
Streams ?


On 19/06/2013 2:05 AM, Brian Goetz wrote:
> The libraries team added the following methods to java.io and java.nio,
> with discussion on corelibs-dev:
> In java.io.BufferedReader:
>    Stream<String> lines()
> In java.nio.Files, static methods for:
>    CloseableStream<Path> list(Path dir) throws IOException;
>    CloseableStream<Path> walk(Path start, int maxDepth,
> FileVisitOption... options) throws IOException
>    CloseableStream<Path> walk(Path start, FileVisitOption... options)
> throws IOException
>    CloseableStream<Path> find(Path start,
>                             int maxDepth,
>                             BiPredicate<Path, BasicFileAttributes> matcher,
>                             FileVisitOption... options)
>          throws IOException
>    CloseableStream<String> lines(Path path, Charset cs) throws IOException
> CloseableStream simply extends Stream and AutoCloseable, making it
> suitable for use with try-with-resources:
> public interface CloseableStream<T> extends Stream<T>, AutoCloseable {
>      void close();
> }
> Should we consider moving AutoCloseable up to Stream and friends, and
> get rid of CloseableStream?

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