I am trying to replace string containing " with \" , below is the program I tried
String s="\"/test /string\"";
s = s.replaceAll("\"", "\\\"");
System.out.println(s);
But I get the same output as the string "/test /string". Why is my replace function is not working. If I do
s = s.replaceAll("\"", "\\\\\"");
then I get the output I want \"/test /string\" . Why is the former dint work , even though in code I am trying to replace " with \"