exists and notExists
Elliotte Harold
elharo at metalab.unc.edu
Tue May 27 07:01:39 PDT 2008
Alan Bateman wrote:
>> (If not, the JavaDoc needs to be clarified.)
> If the javadoc isn't clear then we can improve it. In this case it says
> it returns false "if the file does not exist or its existence cannot be
> determined".
>
But what is gained? I still don't understand in what circumstances
notExists() will tell you something that !exists() does not. Can you
please clarify when
!path.exists() might return a different answer than path.notExists()?
Might they both return false if the existence cannot be determined?
If so, I'd argue that the non-Aristotelian logic here is likely to be
deeply confusing. (It's certainly confusing me.) Better solutions would
be to either
1. Use an enumerated return type rather than a boolean that has three
states: exists, not exists, unknown.
or
2. Throw an IOException if the existence cannot be determined.
I'm not sure which I prefer. I think #2 is probably easier, but I'm not
sure of that. Regardless the current scheme is just asking for confusion.
--
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