Path.checkAccess (6873681)
Mark Thornton
mthornton at optrak.co.uk
Wed Oct 13 11:39:22 PDT 2010
On 13/10/2010 19:07, fm wrote:
> On a related subject, it has been brought up a few times that
> convenience methods such as checkAccess(...) or exists() don't
> guarantee that access or existence to a file hasn't changed between
> the time of the check and the time that the file is actually accessed.
> I think this risk will be understood by programmers and does not
> invalidate the usefulness of these convenience methods. If I can
> handle an alternative case because I did a check first as opposed to
> reacting to it by catching the exception, then this can often be a
> good thing. The IOException hierarchy will always be there as a last
> resort (or safety net) to handling file access that goes wrong for
> some reason.
In my experience the main reason for using check methods has been
because you couldn't programmatically determine the reason for failure
from the IOException (or some methods didn't throw an exception at all
--- File.delete). Given a useful exception heirarchy I would far prefer
to try the operation first and then handle the exception if one arises.
Mark Thornton
More information about the nio-dev
mailing list