来自这个java教程here :
Deleting a File or Directory
You can delete files, directories or links. With symbolic links, the link is deleted and not the target of the link. With directories, the directory must be empty, or the deletion fails.
另一方面来自here :
You need to decide whether you want symbolic links to be followed. If you are deleting files, for example, following symbolic links might not be advisable. If you are copying a file tree, you might want to allow it. By default, walkFileTree does not follow symbolic links.
他们在第二个引用中说,例如,如果您要删除文件,则可能不建议使用符号链接(symbolic link)
但是在第一个引用中明确指出:您可以删除文件、目录或链接。对于符号链接(symbolic link),链接被删除,而不是链接的目标。
如果它只删除链接而不删除目标,为什么在使用Files.walkFileTree
删除时不建议遵循链接?
提前致谢。
最佳答案
符号链接(symbolic link)的问题是您不知道它将把您发送到哪里。因此,如果您递归地删除 /etc/home/Rollerball/opt
,也许您忘记了有一个指向 /bin
的链接,您忘记了考虑。
关于java - 关于用Files.walkFileTree删除符号链接(symbolic link)的查询,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18211377/