Created
December 20, 2014 14:16
-
-
Save fge/2cc1379ddbb88ce35c9b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static void main(String[] args) | |
{ | |
final Map<String, List<String>> map = new HashMap<>(); | |
map.put("foo", Arrays.asList("bar", "baz")); | |
map.put("foo2", Arrays.asList("bar2", "baz2")); | |
map.entrySet().stream().flatMap(e -> { | |
final Stream.Builder<Map.Entry<String, String>> builder | |
= Stream.builder(); | |
final String k = e.getKey(); | |
e.getValue().stream().forEach(v -> builder.accept(new AbstractMap | |
.SimpleEntry<>(k, v))); | |
return builder.build(); | |
}).forEach(System.out::println); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment