更新时间:2023-12-05 12:54:40
当使用 String.replace(String, String)
时,反斜杠不需要转义两次(即使用 replaceAll
- 它处理正则表达式).所以:
When using String.replace(String, String)
the backslash doesn't need to be escaped twice (thats when using replaceAll
- it deals with regex). So:
String rawPath = filePath.replace("\\", "/");
或者使用char
版本:
String rawPath = filePath.replace('\\', '/');