我想把输入的C:\Documents and Settings\Henry\桌面\1\linecounter转换成允许格式,再交给File f=new File(str)处理
用
str=str.replaceAll("\\","/");
编译通过,运行错误
C:\Documents and Settings\Henry\桌面\1\linecounter
Exception in thread "main" java.util.regex.PatternSyntaxException: Unexpected in
ternal error near index 1
\
^
at java.util.regex.Pattern.error(Pattern.java:1650)
at java.util.regex.Pattern.compile(Pattern.java:1403)
at java.util.regex.Pattern.<init>(Pattern.java:1124)
at java.util.regex.Pattern.compile(Pattern.java:817)
at java.lang.String.replaceAll(String.java:2000)
at FilterFile.main(FilterFile.java:26)
26行就是上面的str=str.replaceAll("\\","/");
求解 |
|