That's nothing wrong with that. It's how characters are escaped in a URL. You should use URLDecoder
, which is particularly appropriate because, despite of its name, it does application/x-www-form-urlencoded
decoding:
String decoded = URLDecoder.decode(queryString, "UTF-8");
Then you'll be able to build a map of key/value pairs parsing the query part of the URL, splitting on &
, and using =
to separate the key from the value (which may also be null
).
However note that if the URL is passed as a URI
object, it has a nice getQuery()
which already returns the unescaped text.
If you use the servlet API, you don't have to escape anything because there are nice methods like getParameterMap()
.
%20
. You can:URL = URL.replaceAll("%20", "");