Is there any way in java which can shorten absolute path to directory.
For example:
./data/../system/bin/ => ./system/bin/
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With