Here you can find the source of isSymbolicLink(File file)
Parameter | Description |
---|---|
file | the file to determine |
Parameter | Description |
---|---|
IOException | if the file could not be read. |
public static boolean isSymbolicLink(File file) throws IOException
//package com.java2s; import java.io.File; import java.io.IOException; public class Main { /**/* w w w .j a va2s . co m*/ * Determines if a file is a symbolic link. * * @param file * the file to determine * @return true ifthe file is a symbolic links; false otherwise. * @throws IOException * if the file could not be read. */ public static boolean isSymbolicLink(File file) throws IOException { if (file == null) { throw new NullPointerException("File must not be null"); } File fileInCanonicalDir = null; if (file.getParent() == null) { fileInCanonicalDir = file; } else { File canonicalDir = file.getParentFile().getCanonicalFile(); fileInCanonicalDir = new File(canonicalDir, file.getName()); } return !fileInCanonicalDir.getCanonicalFile().equals(fileInCanonicalDir.getAbsoluteFile()); } }