Possible Duplicate:
Java 1.6 - determine symbolic links
I have 2 files:
/usr/local/sam/icc/tmp/indus_history.txt
/osp/psmf/service/indus/tmp/indus_history2.txt
Parent directory of File 1 is a symbolic link to parent directory of File 2 i.e. :
/usr/local/sam/icc/tmp/ --> /osp/psmf/service/indus/tmp/
Moreover "File 1" is a symbolic link to "File 2" i.e. :
indus_history.txt --> /osp/psmf/service/indus/tmp/indus_history2.txt
getAbsoluteFile() on "File 1" returns /usr/local/sam/icc/tmp/indus_history.txt
getCanonicalFile() on "File 1" returns /osp/psmf/service/indus/tmp/indus_history2.txt
This is correct.
But if I remove the symbolic link between "File 1" and "File 2", and I create a physical "File 1" at /usr/local/sam/icc/tmp/ then the results are :
getAbsoluteFile() on "File 1" returns /usr/local/sam/icc/tmp/indus_history.txt
getCanonicalFile() on "File 1" returns /osp/psmf/service/indus/tmp/indus_history.txt
It is because the Parent directory of "File 1" is a symbolic link.
So how can I check whether "File 1" is a physical file or a symbolic link in its parent directory (i.e. /usr/local/sam/icc/tmp/) ???
Note: I know its simple in JAVA 1.7, but how can I do it with earlier versions of JAVA ?