replaceAll("\\\\", "/");
例如
//获取项目路径,并将\转换为/ File directory = new File("");
String courseFile = directory.getCanonicalPath().replaceAll("\\\\", "/");
注意String a="a\\b"
打印出来后变成a\b
java转义字符处理——“\\”替换为“/”
原文:https://www.cnblogs.com/Pusteblume/p/10202605.html