How do you do RAW/URL encode/decode in JAVA?
Got something which asked URLencoded or RAWURLencoded need to be sent. After looking here and there, did not find any url/rawurl encoder/decoder available. How do you make it?
Example:
String webBrowser = "how=WebRSS&what=Tandory chicken is nice with rice, lets cook for my honey";
String encoded = null;
/**
* Output: how%3DWebRSS%26what%3DTandory+chicken+is+nice+with+rice%2C+lets+cook+for+my+honey
*/
urlencode(webBrowser);
/**
* Output: how%3DWebRSS%26what%3DTandory%20chicken%20is%20nice%20with%20rice%2C%20lets%20cook%20for%20my%20honey
*/
rawurlencode(webBrowser);
postIt(encoded); //!!
For
urlencode/urldecode(the application/x-www-form-urlencoded variants), you can useURLEncoder
andURLDecoder.For the “raw” versions, you can use the
URIclass, which performs this task automatically.