How to convert an Optional into a Stream?

后端 未结 6 1613
孤独总比滥情好
孤独总比滥情好 2020-12-05 03:56

I want to prepend a stream with an Optional. Since Stream.concat can only concatinate Streams I have this question:

How do I convert an Optional

6条回答
  •  孤城傲影
    2020-12-05 04:30

    A nice library from one of my ex collegues is Streamify. A lot of collectors, creating streams from practicly everything.

    https://github.com/sourcy/streamify

    Creating a stream form an optional in streamify:

    Streamify.stream(optional)
    

提交回复
热议问题