private String encodeHttpParameter ( String str ) { //It translates the empty space String encoded = str . replaceAll ( " " , "%20" ) ; //It translates the & symbol encoded = encoded . replaceAll ( "&" , "%26" ) ; // encoded = encoded.replaceAll("$", "%24"); // encoded = encoded.replaceAll("`", "%60"); // encoded = encoded.replaceAll(":", "%3A"); // encoded = encoded.replaceAll("<", "%3C"); // encoded = encoded.replaceAll(">", "%3E"); // encoded = encoded.replaceAll("[", "%5B"); // encoded = encoded.replaceAll("]", "%5D"); // encoded = encoded.replaceAll("{", "%7B"); // encoded = encoded.replaceAll("}", "%7D"); return encoded ; }
It encodes special symbols in their valid representations for http requests .