XMan3 XMan3 - 17 days ago 4x
Java Question

Java - Get final "destination" of a file

I was wondering, how can I find the final destination of a file?

For example, if I write this path:


The path would be simple, but if I type, for example:


Now, I can see that the destination would be ...\2ndDir\file.txt, but how can I run a command to check the destination?


What you want is the canonical path, which is unique for every single file. You basically just need to create a File object and run the getCanonicalPath() method to get what you want.

File f = new File(yourPath);

...checking for exceptions, yada yada.