On top of my head, it will look like this (warning: unchecked):
String url = ...; int s = url.indexOf("?") + 1; while (s > 0) { int e = url.indexOf("=", s); String name = url.substring(s, e), value; s = e + 1; e = url.indexOf("&", s); if (e < 0) value = url.substring(s, e); else value = url.substring(s, e);
Query strings can technically be separated by a semicolon instead of an ampersand, for example name1=value1;name2=value2;... although I have never seen this done in practice. If this bothers you, I'm sure you can fix the code for it.
source share