Skip to content

Instantly share code, notes, and snippets.

@LenarBad
Created April 8, 2019 21:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save LenarBad/17312714eb0c0dfd60f8ef5a3950362f to your computer and use it in GitHub Desktop.
Save LenarBad/17312714eb0c0dfd60f8ef5a3950362f to your computer and use it in GitHub Desktop.
Url query to parameter map
private Map<String, String> queryToMap(String query) throws UnsupportedEncodingException {
Map<String, String> parameters = new HashMap<>();
String[] queryArray = query.split("&");
for (String string : queryArray) {
int idx = string.indexOf("=");
parameters.put(decode(string.substring(0, idx), "UTF-8"), decode(string.substring(idx + 1), "UTF-8"));
}
return parameters;
}
@LenarBad
Copy link
Author

LenarBad commented Apr 8, 2019

More on lenar.io

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment