Does anyone have, or know of, a java class that I can use to manipulate query strings?
Essentially I\'d like a class that I can simply give a query string to and the
SOmething like this
public static Map getQueryMap(String query)
{
String[] params = query.split("&");
Map map = new HashMap();
for (String param : params)
{
String name = param.split("=")[0];
String value = param.split("=")[1];
map.put(name, value);
}
return map;
}
To iterate the map simply:
String query = url.getQuery();
Map map = getQueryMap(query);
Set keys = map.keySet();
for (String key : keys)
{
System.out.println("Name=" + key);
System.out.println("Value=" + map.get(key));
}