java中有没有什么方法可以缩短目录的绝对路径。
例如:
./data/../system/bin/
=> ./system/bin/
最佳答案
是的,使用 http://docs.oracle.com/javase/7/docs/api/java/io/File.html#getCanonicalPath() .
File file = new File("C:/Users/../Users");
System.out.println(file.getAbsolutePath()); // C:\Users\..\Users
System.out.println(file.getCanonicalPath()); // C:\Users
关于java - 如何在 java 中缩短文件路径(获取规范路径)?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26336301/