I believe this answer has exactly what you're looking for. Note that I would have preferred a tag for the language you're using to be sure.
String.replaceAll single backslashes with double backslashes
This code does what I expected it to:
public class JavaFiddle
{
public static void main(String[] args)
{
String myString = "C:\\Text\\Somewhere\\Works";
System.out.println(myString);
String myStringTwo = myString.replace("\\", "\\\\");
System.out.println(myStringTwo);
}
}
Note: What's going on here is the first backslash is an 'Escape Character.' You can't add a backslash directly into a string because it indicates programmatic control. https://en.wikipedia.org/wiki/Escape_character