listFiles() of File not working on symbolic links?
问题 I have the following File object pointing to a directory via symbolic link, File directory = new File("/path/symlink/foo/bar"); String[] files = directory.listFiles(); listFiles() returns null, is this because of the symlink? if yes, how will I go about this if I really want to list the files in bar using the path that contains a symlink? 回答1: According to what I've seen while Googling this puzzling behavior, Java requires that you call .getCanonicalFile() on a File whose path contains a link