在DirectoryWalker类中,我想知道File实例是否实际上是指向目录的符号链接(假设,walker在UNIX系统上行走).鉴于,我已经知道实例是一个目录,以下是确定符号链接的可靠条件吗?
File file;
// ...
if (file.getAbsolutePath().equals(file.getCanonicalPath())) {
// real directory ---> do normal stuff
}
else {
// possible symbolic link ---> do link stuff
}
Run Code Online (Sandbox Code Playgroud)