Top "Java-stream" questions

Use this tag for questions related to the use of the Stream API.

How to compute average of multiple numbers in sequence using Java 8 lambda

If I have collections Point , how do I compute average of x,y using Java 8 stream on a single iteration. …

java java-8 java-stream collectors
Spring repository method which are returning Java 8 stream doesn't close JDBC connection

I have a Spring data repository: @Repository interface SomeRepository extends CrudRepository<Entity, Long> { Stream<Entity> streamBySmth(…

java spring spring-data java-stream spring-jdbc
Collect into Guava's ListMultiMap using Java 8 streams

I am trying to collect into a ListMultiMap using java 8 without using the forEach operation. If I were to write …

java java-8 java-stream guava collectors
How to convert a tree structure to a Stream of nodes in java

I want to convert a tree in a Java8 stream of nodes. Here is a tree of nodes storing data …

tree-traversal java-stream
Simplest way to stream an iterator

Say you want to stream the elements of an iterator; let's use a concrete example of a Scanner, which implements …

java iterator java-8 java-stream iterable
Implementing Java Pivot table using Streams

I have been struggling with this issue for a few days now. I am trying to create Pivot functionality using …

java java-8 pivot java-stream collectors
Java 8 stream to Map<Integer, List<String>>

This is Java object to handle in Java 8 stream private static List<Person> getPersons() { List<Person> …

java java-stream collectors
Java Streams - Standard Deviation

I wish to clarify upfront I am looking for a way to calculate Standard deviation using Streams (I have a …

java java-8 java-stream standard-deviation
How to preserve newlines while reading a file using stream - java 8

try (Stream<String> lines = Files.lines(targetFile)) { List<String> replacedContent = lines.map(line -> StringUtils.…

java java-8 newline java-stream replaceall
How do you group elements in a List<P> to a Map<K, List<V>> while retaining order?

I have a List of Google PlaceSummary objects taken from the Google Places API. I'd like to collect and group …

java java-8 java-stream linkedhashmap collectors