I have started working with Java 8 and trying to convert some loops and old syntax in my code to lambdas and streams.
So for example, I\'m trying to convert this whi
To answer your question, it's a 1-liner:
List list = oldList.stream()
.filter(line -> map.keySet().stream().anyMatch(line::startsWith))
.map(line -> map.entrySet().stream()
.filter(entry -> line.startsWith(entry.getKey()))
.map(entry -> line.replace(entry.getKey(), entry.getValue()))
.findFirst().get())
.collect(Collectors.toList());