List of utility methods to do Is Link File
boolean | isLink(@Nonnull File file) Returns whether the given file is a link if (!file.exists()) { throw new FileNotFoundException(file.getAbsolutePath()); @Nonnull String canonicalPath = file.getCanonicalPath(); @Nonnull String absolutePath = file.getAbsolutePath(); return !absolutePath.equals(canonicalPath); ... |
boolean | isLink(File file) is Link String cnnpath = file.getCanonicalPath();
String abspath = file.getAbsolutePath();
return !abspath.equals(cnnpath);
|
boolean | isLink(File file) is Link try { if (!file.exists()) { return true; } else { String cnnpath = file.getCanonicalPath(); String abspath = file.getAbsolutePath(); return !abspath.equals(cnnpath); } catch (IOException ex) { System.err.println(ex); return true; |
boolean | isLink(File file) Return true if the specified file is a link Be careful, it does work in almost case, but not all if (file == null) return false; final File canon; if (file.getParent() == null) canon = file; else canon = new File(file.getParentFile().getCanonicalFile(), file.getName()); return !canon.getCanonicalFile().getAbsolutePath().equalsIgnoreCase(canon.getAbsolutePath()); ... |
boolean | isLink(final File file) Checks if the given File Object may be a symbolic link. For a link that actually points to something (either a file or a directory), the absolute path is the path through the link, whereas the canonical path is the path the link references. Dangling links appear as files of size zero, and generate a FileNotFoundException when you try to open them. try { if (!file.exists()) { return true; String cnnpath = file.getCanonicalPath(); String abspath = file.getAbsolutePath(); return !abspath.equals(cnnpath); } catch (IOException ex) { ... |
boolean | isLink(java.io.File f) is Link try { String ap[] = f.getAbsolutePath().split(java.io.File.pathSeparator); String cp[] = f.getCanonicalPath().split(java.io.File.pathSeparator); return !ap[ap.length - 1].equals(cp[cp.length - 1]); } catch (Throwable t) { return false; |