Skip to content

Instantly share code, notes, and snippets.

@smallsong
Created July 16, 2018 08:04
Show Gist options
  • Save smallsong/61c65ecf7449ab39c7c14260ca55ff76 to your computer and use it in GitHub Desktop.
Save smallsong/61c65ecf7449ab39c7c14260ca55ff76 to your computer and use it in GitHub Desktop.
map to queryString
public static String mapToQueryString(Map<String, String> map) {
StringBuilder string = new StringBuilder();
String queryString = map.entrySet()
.stream()
.map(Object::toString)
.collect(joining("&"));
if(map.size() > 0) {
string.append("?");
}
string.append(queryString);
return string.toString();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment