1

Possible Duplicate:
Java 1.6 - determine symbolic links

I have 2 files:

  1. /usr/local/sam/icc/tmp/indus_history.txt

  2. /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 ?

Community
  • 1
  • 1
Tirthankar
  • 565
  • 1
  • 6
  • 10
  • I already checked the duplicate question but both getAbsoluteFile() and getAbsolutePath() doesn't serve my purpose. Its because the parent directory of the symbolic link is also a symbolic link. Thats why i am facing the problem – Tirthankar Dec 11 '12 at 03:49
  • Can you guys have a second look on my question @Vash ????? – Tirthankar Dec 11 '12 at 03:54
  • I think this is more about concept. That physical file can not exists in symbolic link directory. As this directory do not exists, there fore that phisical file is stored also in physical directory as when you remove then symbolic link the file will not be removed. Does it ? – Damian Leszczyński - Vash Dec 11 '12 at 08:50

0 Answers0