replaceAll("\\", "/");
例如
//获取项目路径,并将转换为/ File directory = new File("");
String courseFile = directory.getCanonicalPath().replaceAll("\\", "/");
注意String a="a\b"
打印出来后变成a