mkdir()和mkdirs()区别

来源:互联网 发布:agile java被淘汰了吗 编辑:程序博客网 时间:2024/06/08 02:39

刚使用JAVA或者写Android都会傻傻分不清mkdir()和mkdirs()有什么分别。

其实很简单mkdir()只能在下一级目录里创建文件夹,不能带多级路径。

原文:Creates the directory named by the trailing filename of this file. Does not create the complete path required to create this directory.

而mkdirs()则不需要在上级文件夹,直接通过路径来进行创建。

原文:Creates the directory named by the trailing filename of this file, including the complete directory path required to create this directory.


在使用mkdir()时可以配合getFilesDir()来使用,如果知道完整路径,还是直接使用mkdirs()比较好。

原创粉丝点击