Register a Stream “completion” hook

后端 未结 5 1302
长情又很酷
长情又很酷 2020-12-15 03:46

Using the Java 8 Stream API, I would like to register a \"completion hook\", along the lines of:

Stream stream = Stream.of(\"a\",          


        
5条回答
  •  没有蜡笔的小新
    2020-12-15 04:20

    Check out these complete implementations of AutoClosingReferenceStream, AutoClosingIntStream, AutoClosingLongStream and AutoClosingDoubleStream at the open-source project Speedment https://github.com/speedment/speedment/tree/master/src/main/java/com/speedment/internal/core/stream/autoclose

    The solution is similar to the one mentioned by @LukasEder

提交回复
热议问题