In my program I am dealing with files moved by other applications to a common shared mount point in NFS. In around 0.01% of the time my File.exists()
check fails saying that the file does not exists, but when I try a ls -l
on the directory I can see the file seating there. Any reason for such a behavior and how to rectify it.
Asked
Active
Viewed 607 times
0

Acharya
- 97
- 4
-
3show some code please – Aliaksei Bulhak Apr 21 '13 at 15:16
-
3How are you making sure the file didn't appear between the time your code checks and the time you run ls? – Mat Apr 21 '13 at 15:17
-
elaborate your question or we would not be able to help you. – Anirudha Apr 21 '13 at 15:17
-
Here is the code: `File f = new File(filePath); if(f.exists()){...}else{logger.info("No file exists")` In few occasions the else part gets executed, and when I get that in the log I try to check in few minutes time to see if the file is actually not there using `ls` – Acharya Apr 21 '13 at 15:27
-
Wel I got something here http://stackoverflow.com/questions/3833127/alternative-to-file-exists-in-java it seems to be a NFS issue. But is there any alternatives. – Acharya Apr 21 '13 at 15:43
-
Not sure whether it will help but have you thought about trying something like Apache Commons VFS http://commons.apache.org/proper/commons-vfs another option would be to try using JNI/JNA. – Paul H Apr 21 '13 at 18:31
-
Thats something new to me ! But are you saying VFS will not have the same issues that I am facing because of NFS ? – Acharya Apr 22 '13 at 13:21