public static String escapePath(String path)
{
return path.replace("\\", "\\\\");
}
The \ is doubled since it must be escaped in those strings also.
Anyway, I think you should use System.getProperty("file.separator"); instead of \.
Also the java.io.File has a few methods useful for file-system paths.