java怎样把反斜杠"\"转成正斜杠"/"?
程序员文章站
2022-03-17 19:09:23
...
反斜杠为"\",正斜杠为"/"
public class Test { public static void main(String[] args) { String path = "D:\\FTP\\admin\\bird.gif"; System.out.println(path); //JAVA中正则表达式,用"\\\\"表示"\" path = path.replaceAll("\\\\", "/"); System.out.println(path); } }
输出结果为:
D:\FTP\admin\bird.gif
D:/FTP/admin/bird.gif