How to check if a file is readable?

前端 未结 5 2226
滥情空心
滥情空心 2020-12-15 11:50

I\'m writing Java 6 application and I have to check if a file is readable. However, on Windows canRead() always returns true. So I see that probabl

5条回答
  •  一向
    一向 (楼主)
    2020-12-15 12:34

    You only need to know if it's readable if you are going to read it. So, just try to read it, when you need to, and deal with it if you can't. The best way to test the availability of any resource is just to try to use it and deal with the exceptions or errors as they arise. Don't try to predict the future.

提交回复
热议问题