I have a URL string with replaceable values:
http://DOMAIN:PORT/sendmsg?user=test&passwd=test00&text={CONTENT}
I have to encode the content part, so I tried this:
String tempContent = URLEncoder.encode(content, "UTF-8");
tempContent had this value: This+is+test+one I do not want the + where spaces is. Spaces MUST be represented by %20
Now, I can do this:
String tempContent = content.replaceAll(" ", "%20");
BUT that only covers the spaces and I don't have control over the content input. Is there any other efficient way to encode URL content in Java? URLEncoder does not do what I want.
Thanks in advance..