Skip to content

Instantly share code, notes, and snippets.

@agentgt
Created July 22, 2011 18:15
Show Gist options
  • Select an option

  • Save agentgt/1100030 to your computer and use it in GitHub Desktop.

Select an option

Save agentgt/1100030 to your computer and use it in GitHub Desktop.
Parse URI Query Parameters
public static Map<String, String> parseQueryParameters(String uri, String encoding) {
URI url = toURI(uri);
if (url == null) return null;
List<NameValuePair> nvps = URLEncodedUtils.parse(url, encoding);
LinkedHashMap<String, String> m = new LinkedHashMap<String, String>();
for (NameValuePair nvp : nvps) {
m.put(nvp.getName(), nvp.getValue());
}
return m;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment