Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Java File IO getCanonicalFile() handling Linux Symbolic links

807588Apr 28 2009 — edited Apr 29 2009
Does anyone have any experience using the File.getCanonicalFile() method. I would prefer to use the getCanonicalFile() to obtain the real file pointed to by a symbolic link, rather than the Linux "ls" command.

I currently check for any changes by executing a "ls" every second,when I test the getCanonicalFile() method, I see he doesn't seem to keep up with the real situation on the FileSystem ?

Example:

2009-04-28 13:56:57:575 [00000] TEST: ls file=/ama/log/PPT/ape/feAPE_090428_135651 getCanonicalFile()=/ama/log/PPT/ape/feAPE_090428_135627
2009-04-28 13:56:58:569 [00000] TEST: ls file=/ama/log/PPT/ape/feAPE_090428_135651 getCanonicalFile()=/ama/log/PPT/ape/feAPE_090428_135627
2009-04-28 13:56:59:594 [00000] TEST: ls file=/ama/log/PPT/ape/feAPE_090428_135651 getCanonicalFile()=/ama/log/PPT/ape/feAPE_090428_135627
2009-04-28 13:57:00:592 [00000] TEST: ls file=/ama/log/PPT/ape/feAPE_090428_135651 getCanonicalFile()=/ama/log/PPT/ape/feAPE_090428_135627
2009-04-28 13:57:01:543 [00000] TEST: ls file=/ama/log/PPT/ape/feAPE_090428_135651 getCanonicalFile()=/ama/log/PPT/ape/feAPE_090428_135627
2009-04-28 13:57:02:503 [00000] TEST: ls file=/ama/log/PPT/ape/feAPE_090428_135701 getCanonicalFile()=/ama/log/PPT/ape/feAPE_090428_135627
2009-04-28 13:57:04:058 [00000] TEST: ls file=/ama/log/PPT/ape/feAPE_090428_135701 getCanonicalFile()=/ama/log/PPT/ape/feAPE_090428_135627
2009-04-28 13:57:04:460 [00000] TEST: ls file=/ama/log/PPT/ape/feAPE_090428_135701 getCanonicalFile()=/ama/log/PPT/ape/feAPE_090428_135627
2009-04-28 13:57:05:526 [00000] TEST: ls file=/ama/log/PPT/ape/feAPE_090428_135701 getCanonicalFile()=/ama/log/PPT/ape/feAPE_090428_135701
2009-04-28 13:57:06:546 [00000] TEST: ls file=/ama/log/PPT/ape/feAPE_090428_135701 getCanonicalFile()=/ama/log/PPT/ape/feAPE_090428_135701

Thx.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on May 27 2009
Added on Apr 28 2009
4 comments
516 views