This content has been marked as final. Show 5 replies
I don't know if it is exactly the same, but try the methods here:
Thanks doremifasollatido ,
This url has really helped me.
But I have a small doubt. This URLEncoder changes " "(empty space)
into + symbol. but I want it to convert %20. Can I do this?
I don't think you can get URLEncoder to use %20. You could try the output of URLEncoder with the + and see if your application works with that. An application I'm using claimed it needed +, but %20 works fine for it, too. So, yours might work the other way around (if you didn't write it yourself to only accept %20).
If not, use String.replaceAll to replace the "+" with "%20". Note that replaceAll uses a regular expression, so you'll probably need to quote the "+" as "\\+".
Or, use String.replace(CharSequence, CharSequence) (if on Java 1.5) to replace the literal String "+" with "%20".
ok thanks doremifasollatido.
I have used replaceAll() . your message helps me alot.
Btw, "+" is a valid encoding for a space in URL encoding, in addition to "%20". Its the only character with a non-default encoding (i.e. not %nn), as far as I know.