문제

im writing a little project, that open files or shortcuts. In process I found problem.

Question is simple. How can I get difference btw file or shortcut? What java commands should I use and search for?

Example

if (fileIsShortcut) {
    return variable1;
} else {
    return variable2;
}

I hope you understand my problem.

도움이 되었습니까?

해결책

use this code

public static boolean isSymlink(File file) throws IOException {
  if (file == null)
    throw new NullPointerException("File must not be null");
  File canon;
  if (file.getParent() == null) {
    canon = file;
  } else {
    File canonDir = file.getParentFile().getCanonicalFile();
    canon = new File(canonDir, file.getName());
  }
  return !canon.getCanonicalFile().equals(canon.getAbsoluteFile());
}
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top