Skip to content

Instantly share code, notes, and snippets.

@dfparker2002
Forked from dtulig/mapsplitter.java
Created June 26, 2016 23:37
Show Gist options
  • Save dfparker2002/9463653fe53a907c2a94bd54b77a3347 to your computer and use it in GitHub Desktop.
Save dfparker2002/9463653fe53a907c2a94bd54b77a3347 to your computer and use it in GitHub Desktop.
Example of using Guava's MapSplitter
final String stringToSplit = "dave:123, john:314,, matt:989";
final Map<String, String> splitKeyValues = Splitter.on(",")
.omitEmptyStrings()
.trimResults()
.withKeyValueSeparator(":")
.split(stringToSplit);
// Map Contents: {dave=123, john=314, matt=989}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment