I have to replace all withe space in a string with %20.
I try to use the method replaceAll
in this mode title.replaceAll(" ", "%20");
(obviously title is a String) but this doesn't work and the results is the initial string with all white space
Solution
Don't use replace all I find it doesn't ever work as expected. Just String.replace and that should get the job done just fine.
public static void main (String [] args) {
String test = "H E L L O";
test = test.replace(" ", "%20");
System.out.println (test);
}
Result
H%20E%20L%20L%20O