Is it possible to do a lazy groupby, returning a stream, in java 8?
I have some large-ish text files that I want to process by grouping its lines. I tried to use the new streaming features, like return FileUtils.readLines(...) .parallelStream() .map(...) .collect(groupingBy(pair -> pair[0])); The problem is that, AFAIK, this generates a Map. Is there any way to have high level code like the one above that generates, for example, a Stream of Entries? UPDATE : What I'm looking for is something like python's itertools.groupby . My files are already sorted (by pair[0]), I just want to load the groups one by one. I already have an iterative solution. I'm just