java代码
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