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
final Map<String, String> input = new HashMap<String, String>() {{ | |
put("param", "v"); | |
put("p2", "v2"); | |
put("q", "java"); | |
}}; | |
final String result = Joiner.on("&") | |
.withKeyValueSeparator("=") | |
.join(input); |
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
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()); | |
} | |
} |
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
final String stringToSplit = "dave ,john,, matt"; | |
final Iterable<String> result = Splitter.on(",") | |
.omitEmptyStrings() | |
.trimResults() | |
.split(stringToSplit); | |
// Result: ["dave", "john", "matt"] |
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
final String stringToSplit = "dave,john,matt"; | |
final Iterable<String> result = Splitter.on(",").split(stringToSplit); | |
// Result: ["dave", "john", "matt"] |
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
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} |
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
(function() { | |
function getRequest() { | |
var a = null; | |
if (window.XMLHttpRequest) { | |
try { | |
a = new XMLHttpRequest; | |
} | |
catch(c) { | |
} | |
} else if (window.ActiveXObject) { |
NewerOlder