Here you can find the source of isSymbolicLink(File file)
public static boolean isSymbolicLink(File file)
//package com.java2s; //License from project: Apache License import java.io.File; import java.io.IOException; public class Main { public static boolean isSymbolicLink(File file) { try {/*from w ww.ja va 2 s . c o m*/ final File canonicalFile = file.getCanonicalFile(); final File absoluteFile = file.getAbsoluteFile(); final File parentFile = file.getParentFile(); // a symbolic link has a different name between the canonical and absolute path return !canonicalFile.getName().equals(absoluteFile.getName()) || // or the canonical parent path is not the same as the file's parent path, // provided the file has a parent path parentFile != null && !parentFile.getCanonicalPath().equals(canonicalFile.getParent()); } catch (IOException e) { // error on the side of caution return true; } } }