I'm trying the following code in Java in which I need to replace a back slash with a forward slash but I can't.
package superpkg;
import java.util.regex.Matcher;
final public class Super
{
public static void main(String[] args)
{
String string="xxx\\aaa";
string.replaceAll("\\\\", "/");
System.out.println(string);
string.replaceAll(Matcher.quoteReplacement("\\"), "/");
System.out.println(string);
}
}
In both the cases, it displays the following output.
xxx\aaa
xxx\aaa
means that the back slash in the given string is not replaced with the forward slash as expected. How can it be achieved?