exists and notExists
Elliotte Harold
elharo at metalab.unc.edu
Mon May 26 17:59:22 PDT 2008
Alan Bateman wrote:
> An existence check yields one of three answers: the file exists, the
> file does not exist, or it can't say (due a permission problem for
> example). The exists and notExists are convenience methods for cases
> where you want to take action when a file is confirmed to exist (at that
> point in time), or confirmed to not exist.
>
As I read the JavaDoc, the only reason the exists() method won't be able
to say is if it throws a SecurityException. Correct? (If not, the
JavaDoc needs to be clarified.)
I don't feel like notExists is convenient enough to justify its
existence. Presumably if one cannot tell if a file exists, one cannot
tell if it doesn't exist either. Both are SecurityExceptions. Can you
imagine the bloat if every isXXX() method in Java was matched by a
isNotXXX() method? Let's not start down this path. A single exists()
method is fully sufficient.
--
Elliotte Rusty Harold elharo at metalab.unc.edu
Java I/O 2nd Edition Just Published!
http://www.cafeaulait.org/books/javaio2/
http://www.amazon.com/exec/obidos/ISBN=0596527500/ref=nosim/cafeaulaitA/
More information about the nio-discuss
mailing list