[英]Detect if a File is a symbolic link in Java 8
How can I detect whether a File
f
is a symbolic link (in the unix sense, as created by ln -s source target
) or a normal file/directory? 如何检测
File
f
是符号链接(在Unix上,由ln -s source target
创建)还是普通的文件/目录?
I am using Java 8
and OS X
, CentOS
and Ubuntu
. 我正在使用
Java 8
和OS X
, CentOS
和Ubuntu
。
In this question they kind of solve it for Java 6
. 在这个问题上,他们为
Java 6
解决了这一问题 。 Is there something better in Java 8
? Java 8
有更好的东西吗?
I would like to later use this in order to handle files and directories on a different file system in a different way. 我想稍后使用它以便以不同的方式处理不同文件系统上的文件和目录。
看一下从Java 7开始可用的java.nio.file.attribute.BasicFileAttributes.isSymbolicLink()
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.