XMan3 XMan3 - 1 year ago 74
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?

Answer Source

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.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download