一个神奇的问题,有大神帮忙解释一波吗
代码:String strPath = "/test/";
System.out.println(strPath);
File file = new File(strPath);
System.out.println(file.getCanonicalPath().replaceAll("\\\\", "/"));
控制台输出:
/test/
/test2
2018-04-24 15:55
2018-04-24 20:41
程序代码:String strPath = "/test/";
System.out.println(strPath);
File file = new File(strPath);
String absolutePath = file.getAbsolutePath();
System.out.println(absolutePath);
String canonicalPath = file.getCanonicalPath();
System.out.println(canonicalPath);
System.out.println(canonicalPath.replaceAll("\\\\", "/"));/test/ D:\test D:\test D:/test

2018-04-24 20:45
2018-04-25 09:34