Deleting symbolic links via the java.nio.file.Path API

fm fudmail at gmail.com
Fri Oct 8 22:32:10 PDT 2010


> If someone really needs to then they can use readBasicFileAttributes specifying
> NOFOLLOW_LINKS.

Right. But it is currently not possible to check that a symbolic link
exists without the possibility of an IOException being thrown by the
readBasicFileAttributes method.

> It's not clear to me that changing the exists method is worth it.

The only downside to changing the method (from what I can see) would
be adding slightly to the conceptual complexity of the method (i.e.,
there would be one more optional argument for the programmer to have
to think about or ignore).

My 2 cents is that the exists, notExists, and checkAccess methods
should have the following signatures:

void checkAccess(AccessMode[] modes, LinkOption... options)

boolean exists(LinkOption... options)

boolean notExists(LinkOption... options)

This would add convenience by enabling the programmer to avoid
accessing file attributes (and handling an IOException) just to
determine if something exists on the file system that corresponds to a
java.nio.file.Path instance.


More information about the nio-dev mailing list