Noticed this today.
Given that a file named “existing” exists in the PWD of a java process (windows).
new File("existing").exists() => true
new File("", "existing").exists() => false
new File(".", "existing").exists() => true
I would have anticipated, from the javadoc that the system dependent default directory would be “.” and these all be true, so this unexpected.
Thoughts?
Thanks!
-roger-
The two argument constructor expects a parent directory name, so your second line looks for a file whose relative path is “/existing”. On a linux type system, “/” is the root (as far as I know), so /existing is very unlikely to exist. On windows, I’m not sure what it interprets that as by default, but if I open up a command line and say
cd /Desktop(working directory being my user folder) it says it can’t find the path specified.