Use this tag for questions related to the use of the Stream API. It was introduced in Java 8 and supports functional-style operations on streams of values, such as filter-map-reduce pipelines on collections.

learn more…| top users | synonyms

3
votes
1answer
33 views

Spark streaming one log file with java doesn't generate any output

I want to stream a log file by java and spark. My code is simple:String base="c:/test";SparkConf conf=new SparkConf().setAppName("First_App").setMaster("local[2]");...
7
votes
5answers
139 views

Java streams vs Iterators

I have been playing with the new and shiny functional part of Java and one of the things that puzzle me the most are streams? What is their use? On Google I mostly found explanations of how to use ...
2
votes
3answers
94 views

Java8 Streams - Compare Two List's object values and add value to sub object of first list?

I have two objects:public class ObjectOne {private String id;private String name;private String school;private String score; //Default score is null..getters and setters..}public ...
2
votes
2answers
54 views

java 8 - Way to filter list of values from a map?

I have a mapMap<Integer, List<Person>> personsByIdand a predicate function callbak(person) -> person.getPersonID() > 10 && person.blabla() !=nullI need to filter the ...
0
votes
1answer
44 views

How to wait until list of tasks are done using CompletableFuture ?

I am experimenting with CompletableFutures and hope someone could help turn head around. My algorithm below:I have list of Articles.I call REST API to get Categories for each Article.I save ...
-4
votes
2answers
74 views

List elements as comma seperated string - split and add to list using java 8 streams [on hold]

Lets say I have a List<String> where an element could have a comma seperated String. List<String> list=new ArrayList<>();list.add("1");list.add("2,3,4,5");list.add("6,7");...
5
votes
2answers
133 views

Java 8 Streams - Collecting Values that could be null

I have the following code: private static <T> Map<String, ?> getDifference(final T a, final T b, final Map<String, Function<T, Object>> fields) {return fields....
2
votes
2answers
90 views

Pros and Cons of usage forEach and Stream [duplicate]

Starts from java 8 to iterate throug list I can use both:List list=new ArrayList();1. list.forEach(...)2. list.stream().forEach(...)Is it any advantages of using second case? To convert list ...
0
votes
2answers
73 views

Java Streams Exception handling. Best way for cleaner code

I have the below code import java.util.function.BiConsumer;public class ExceptionHandlingLambda {public static void main(String[] args) {int [] someNumbers={ 1, 2, 3, 4 };...
1
vote
1answer
52 views

How to use thenComparing in java stream

I have a map with strings as values. I want to sort it firstly by length, and if length of the strings is the same, i want to sort it alphabetic. I wrote those code : String out=outMap.values()....
-3
votes
0answers
44 views

Filtering multiple nested Lists using streams

I'm relatively new to Java and streams, and am having trouble understanding if they would be able to handle the problem I have in front of me in a simple fashion:I have a List of objects (Obj1). For ...
2
votes
1answer
62 views

Custom Tree Node search algorithm in java

I am trying to search the child nodes based on the search query. I also need to keep their parents in the list. I am facing difficulty iterating and filtering the full tree that has been populated ...
3
votes
2answers
90 views

Convert List of List of Elements to Map < K, List<V>>

I have following structure.Request {List<Param> paramList;Date startDate;Date endDate;}Param {String paramId;List<DataParam> dataParams; }DataParam {...
3
votes
2answers
69 views

Calculate sum using Java Stream API grouping by field

You have two classes:Account: number: String, balance: LongTransaction: uuid: String, sum: Long, account: AccountBoth classes have getters for all fields with the corresponding names (getNumber(),...
-1
votes
1answer
63 views

Java 8 Stream - GroupingBy Class

i have a problem with groupingBy method.I use an example:Suppose to have a List<Person> where Person.class and City.class are like thisclass Person{String name;String surname;...

153050per page
angop.ao, elkhabar.com, noa.al, afghanpaper.com, bbc.com, time.com, cdc.gov, nih.gov, xnxx.com, github.com,