File.mkdir or mkdirs return false - Reason?

前端 未结 4 1278
我寻月下人不归
我寻月下人不归 2020-12-09 07:33

Why file.mkdir is returning false?

Google indicates that there could be several reasons (e.g. security, permissions, pathname, etc).

My questions:

4条回答
  •  轮回少年
    2020-12-09 07:58

    1. No, there's no way to find the exact reason mkdirs() returns false, at least not from within Java, as it would probably be OS dependent.

    2. A SecurityException is thrown if there is a security violation in the SecurityManager's checkRead() and checkWrite() methods. The exception isn't thrown if there is an OS permissions issue.


    Additionally, note that if you call File.mkdir(), and the parent directory doesn't exist, mkdir() will return false. However, calling File.mkdirs() will create the non-existent parent directories.

提交回复
热议问题