File.exists() returns false when file exists

I am seeing the following situation on Windows 7:

file.exists() == false
file.getAbsoluteFile().exists() == true

The file in question is “var\log”, the absolute path does refer to an existing file that is in a normal subdirectory (not a virtual store). This is seen from the IDE.

The operations running on file are resolved against the current directory, while getAbsolutePath resolves against user.dir. If these two paths do not match, you get conflicting results.

See https://bugs.java.com/bugdatabase/view_bug?bug_id=4483097

Leave a Comment