public static void main(String[] args) {
String strPath = "D:\\apache-tomcat-6.0.43\\bin";
String strPath2 = "D:/apache-tomcat-6.0.43/bin";
String strPath3 = "D:/apache-tomcat-6.0.43/bin";
//替换成D:/apache-tomcat-6.0.43/bin
strPath=strPath.replaceAll("\\\\", "/");
System.out.println(strPath);
//替换成D:\apache-tomcat-6.0.43\bin
strPath2=strPath2.replaceAll("/", "\\\\");
System.out.println(strPath2);
//替换成D:\\apache-tomcat-6.0.43\\bin
strPath3=strPath3.replaceAll("/", "\\\\\\\\");
System.out.println(strPath3);
}
java左右斜杠的相互转化
最新推荐文章于 2023-03-31 11:35:26 发布