Last active
October 24, 2018 12:58
-
-
Save claudioaltamura/0ba84ea4d0bd44519f752e4cf880731e to your computer and use it in GitHub Desktop.
Map string with key values to Map in Java
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 class StringToMap { | |
public static Map<String, String> map(String str) { | |
return (HashMap<String, String>) Arrays | |
.asList(str.split(",")) | |
.stream().map(s -> s.split("=")) | |
.collect(Collectors.toMap(e -> e[0], e -> e[1])); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment