code: public static boolean isSymbolicLink(File file) throws IOException {
      // first try using Java 7
      try {
        // use reflection here
        Class<?> filesClass = Class.forName("java.nio.file.Files");
        Class<?> pathClass = Class.forName("java.nio.file.Path");
        Object path = File.class.getMethod("toPath").invoke(file);
        return ((Boolean) filesClass.getMethod("isSymbolicLink", pathClass).invoke(null, path))
            .booleanValue();
      } catch (InvocationTargetException exception) {
        Throwable cause = exception.getCause();
        Throwables.propagateIfPossible(cause, IOException.class);
        // shouldn't reach this point, but just in case...
        throw new RuntimeException(cause);
      } catch (ClassNotFoundException exception) {
        // handled below
      } catch (IllegalArgumentException exception) {
        // handled below
      } catch (SecurityException exception) {
        // handled below
      } catch (IllegalAccessException exception) {
        // handled below
      } catch (NoSuchMethodException exception) {
        // handled below
      }
      // backup option compatible with earlier Java
      // this won't work on Windows, which is where separator char is '\\'
      if (File.separatorChar == '\\') {
        return false;
      }
      File canonical = file;
      if (file.getParent() != null) {
        canonical = new File(file.getParentFile().getCanonicalFile(), file.getName());
      }
      return !canonical.getCanonicalFile().equals(canonical.getAbsoluteFile());
    }
docs: Returns whether the given file is a symbolic link.
  
  @since 1.16