We talk about java 1.6 here. Since symoblic link is not yet supported, how can examine the existence of them.
1: tell wheather the link file itself exists (return tr
The following should give you a start:
if (file.exists() && !file.isDirectory() && !file.isFile()) {
// it is a symbolic link (or a named pipe/socket, or maybe some other things)
}
if (file.exists()) {
try {
file.getCanonicalFile();
} catch (FileNotFoundException ex) {
// it is a broken symbolic link
}
}
EDIT : The above don't work as I thought because file.isDirectory() and file.isFile() resolve a symbolic link. (We live and learn!)
If you want an accurate determination, you will need to use JNI to make the relevant native OS-specific library calls.