Backslashes in java are escape tokens. To use them as character literals they need to be preceded by a backslash, ie, escaped. So if you want '\' to appear you have to write it as '\\'.
String escapedLetters = "C:\file\test.txt";
System.out.println("escapedLetters = " + escapedLetters);
String url = "C:\\file\\test.txt";
System.out.println("url = " + url);
String converted = url.replace('\\','/');
System.out.println("converted = " + converted);