Skip to content

Instantly share code, notes, and snippets.

@dtulig
Created October 8, 2011 03:19
Show Gist options
  • Save dtulig/1271799 to your computer and use it in GitHub Desktop.
Save dtulig/1271799 to your computer and use it in GitHub Desktop.
final Map<String, String> resultMap = new HashMap<String, String>();
for (String val: "dave:123, john:314,, matt:989".split(",")) {
if (val != null && ! "".equals(val.trim())) {
final String[] keyValue = val.split(":");
resultMap.put(keyValue[0].trim(), keyValue[1].trim());
}
}
// resultMap: {dave=123, john=314, matt=989}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment