java怎样把反斜杠"\"转成正斜杠"/"?

时间:2022-12-02 14:44:41

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