Identifying resource-using streams

Peter Levart peter.levart at gmail.com
Mon Apr 21 19:31:33 UTC 2014


On 04/21/2014 08:42 AM, Timo Kinnunen wrote:
> almost all of the cases where I plan to use Streams involve reading the contents of directories, reading the contents of files or reading the contents of JAR files. All are cases where resources are involved and the processing too complicated to fit in a single method.
>
> Using things like a Supplier<FileInputStream> it would be very easy to delay the resource acquisition so that it could happen inside the terminal method, making every terminal naturally responsible for releasing resources.
>
> All of the above brings up another unfortunate feature of the API: a Stream is very close to being an immutable stateless builder for stream-like processing but it is neither immutable nor stateless.
>
> If Stream was immutable and stateless then you would be able to reuse, rerun and combine Streams freely and all the processing would be happening in a single place, inside terminals. Because where else could it happen?

Hi,

Here's some ideas I played with while Streams API was still being developed:

     https://github.com/plevart/streamx

I have just updated it so that it compiles with released JDK 8 API.


Regards, Peter



More information about the lambda-dev mailing list