Skip to content

Tag: java-stream

Merging multiple lists to one list of Objects in stream?

I have code like this. It uses JSoap library. I am getting titles, magnets, seeds, leechers (these two together as TorrentStats) from torrent site. Now I want to merge them inside one List, of course it’s pretty easy to do it in standard for loop but is there any way to map or flatmap them in stream? An…

Ignore exception in stream operations

Assuming you have an exception (checked/unchecked) in a stream operation and you want to ignore from now on this element. The stream must not be aborted, just ignoring elements throwing exceptions. I explicitly avoid saying skip, because it is a stream operation. So the example is using the map() operation fo…

How can I create a stream of objects?

Let’s say I have: and Then in a service, I have: It is not allowed to do the following: But ultimately, I have other classes that would share this interface and would want to do: Is there a way around this? Like using flatMap? (I noticed that if I have a wrapper class on a List of SomeClass objects, I