Mixing java collections with scala streams

To convert a java collection to a scala stream, you can use the scala-java8-compat library (https://github.com/scala/scala-java8-compat).

You can just import scala.compat.java8.StreamConverters._ which provides a toScala function on the java stream which allows the following code:


This results into a scala stream.

To convert a scala stream back to a java collection, you only have to import collection.JavaConversions._ which provides a set of implicit conversions.

This way you can just return a scala stream in a function that has a List as the return type.