Alternative to File.exists() in Java

后端 未结 6 1379
没有蜡笔的小新
没有蜡笔的小新 2020-12-06 07:14

I never thought it would happen to me, but I ran into my first bug in Java:

http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=5003595

I\'m pretty much in th

6条回答
  •  爱一瞬间的悲伤
    2020-12-06 07:36

    What happens if File.exists() returns true, then someone deletes the file/your NFS mount goes away, then you try and open the file? Basically, File.exists() is useless since you need to handle the exceptions that can arise from opening the file anyway.

提交回复
热议问题