Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

I think the title says it all. How would I specify FOLLOW_LINKS? Why create an enum with just one option? For example, the method java.nio.file.Files.getLastModifiedTime(Path, LinkOption...) takes an array of LinkOption-s as argument. You have to pass something, yet you can only pass the one option available. This surprised me, and would like to know more about it.

like image 538
Peter Perháč Avatar asked Nov 18 '13 16:11

Peter Perháč


1 Answers

Following links is the default behavior. I.e., if you don't specify NOFOLLOW_LINKS, then links are followed.

From the documentation of the Files.getLastModifiedTime() method (emphasis mine):

The options array may be used to indicate how symbolic links are handled for the case that the file is a symbolic link. By default, symbolic links are followed and the file attribute of the final target of the link is read. If the option NOFOLLOW_LINKS is present then symbolic links are not followed.

like image 184
matts Avatar answered Oct 05 '22 14:10

matts