Top "Java-stream" questions

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

Java 8 Stream with batch processing

I have a large file that contains a list of items. I would like to create a batch of items, …

java java-8 batch-processing java-stream
Copy a stream to avoid "stream has already been operated upon or closed"

I'd like to duplicate a Java 8 stream so that I can deal with it twice. I can collect as a …

java lambda java-8 java-stream
Java 8 toMap IllegalStateException Duplicate Key

I have a file which contains data in the following format 1 2 3 I want to load this to map as {(1-&…

java java-8 java-stream collectors
Java 8 apply function to all elements of Stream without breaking stream chain

Is there a way in Java to apply a function to all the elements of a Stream without breaking the …

java java-8 java-stream chaining
Java 8 Stream String Null Or Empty Filter

I've got Google Guava inside Stream: this.map.entrySet().stream() .filter(entity -> !Strings.isNullOrEmpty(entity.getValue())) .map(obj …

java java-8 guava java-stream
Collect successive pairs from a stream

Given a stream such as { 0, 1, 2, 3, 4 }, how can I most elegantly transform it into given form: { new Pair(0, 1), new Pair(1, 2), new …

java java-8 java-stream
How to apply multiple predicates to a java.util.Stream?

How can I apply multiple predicates to a java.util.Stream's filter() method? This is what I do now, but …

java lambda java-8 java-stream predicate
Word frequency count Java 8

How to count the frequency of words of List in Java 8? List <String> wordsList = Lists.newArrayList("hello", "bye", "…

java java-8 java-stream word-count
Java stream toArray() convert to a specific type of array

Maybe this is very simple but I'm actually a noob on Java 8 features and don't know how to accomplish this. …

java arrays java-8 java-stream
Java contains vs anyMatch behaviour

So if I have a Name object and have an ArrayList of type Name (names), and I want to ascertain …

java java-stream equality