Java Is Symbolic Link isSymlink(final String path)

Here you can find the source of isSymlink(final String path)

Description

is Symlink

License

Apache License

Declaration

public static boolean isSymlink(final String path) throws IOException 

Method Source Code


//package com.java2s;
//License from project: Apache License 

import java.io.File;
import java.io.IOException;

public class Main {
    public static boolean isSymlink(final String path) throws IOException {
        final File file = new File(path);
        final File fileInCanonicalDir;

        if (file.getParent() == null) {
            fileInCanonicalDir = file;/*from   www .j  av  a2s . com*/
        } else {
            fileInCanonicalDir = new File(file.getParentFile().getCanonicalFile(), file.getName());
        }

        final File canonicalFile = fileInCanonicalDir.getCanonicalFile();
        final File absoluteFile = fileInCanonicalDir.getAbsoluteFile();
        return !canonicalFile.equals(absoluteFile);
    }
}

Related

  1. isSymlink(File file)
  2. isSymlink(File file)
  3. isSymlink(File file)
  4. isSymLink(File symlinkFile)
  5. isSymlink(final File file)