Skip to content

Instantly share code, notes, and snippets.

@dtulig
Created October 8, 2011 02:27
Show Gist options
  • Star 6 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save dtulig/1271761 to your computer and use it in GitHub Desktop.
Save dtulig/1271761 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