可能重复替换斜线:
Hints for java.lang.String.replace problem?
Using string.replace() in Java如何使用下划线
为什么 “/” 不通过 “_” 代替?
public static void main(String[] args) throws IOException {
String file = "A/B";
file.replaceAll("/", "_");
System.out.println(file);
}
此外,当你需要的是'replace'不使用'replaceAll'。这只是要求麻烦。 –