Java 7 - LinkOption - why is NOFOLLOW_LINKS the only option available?

I think the name says it all. How do I specify FOLLOW_LINKS? Why create an enumeration in only one way? For example, the java.nio.file.Files.getLastModifiedTime (Path, LinkOption ...) method takes an array of LinkOption-s as an argument. You have to convey something, but you can only convey one option. This surprised me, and I would like to know more about it.

+6
source share
2 answers

Below are the default links. Ie if you did not specify NOFOLLOW_LINKS, then links follow.

From the documentation of the Files.getLastModifiedTime() method (highlighted by me):

An array of options can be used to indicate how symbolic links are handled for the case when the file is a symbolic link. By default, symbolic links are used and the file attribute of the final destination of the link is read. If the NOFOLLOW_LINKS option is present, then symbolic links are not respected.

+3
source

What confuses me a bit is that the LinkOptions argument for Files.exists () is a vararg argument, a fact that I didn't recognize right away ... you can just leave it. Setting it to null will throw an exception.

+1
source

Source: https://habr.com/ru/post/958323/


All Articles