can File.exists can return false if the file exists?
sean.bridges at gmail.com
Thu Apr 4 17:14:01 UTC 2019
Is it possible for File.exists(...) to return false even if the file
The java docs for File.exists say,
"return true if and only if the file or directory denoted by this abstract
pathname exists; false otherwise"
Looking at the implementation, the method does,
s.getBooleanAttributes(this) & FileSystem.BA_EXISTS) != 0
But FileSystem.getBooleanAttributes says,
"Return the simple boolean attributes for the file or directory denoted
by the given abstract pathname, *or zero if it does not exist or some*
* other I/O error occurs*."
So it seems that File.exists can return false for files which exist.
I think we ran into this on a linux server which reached the limit on open
file handles, and File#exists returned false even though the file existed.
Is there a way to reliably tell in java if a files exists. Even a method
which returned true/false/unknown would be preferable.
More information about the core-libs-dev