How to shorten the file path (get the canonical path) in java?
1 answer
Yes, use 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
+5
source to share