-
mkdir
public boolean mkdir()
Creates the directory named by this abstract pathname.-
Returns:
-
true
if and only if the directory was created;false
otherwise
Throws:
-
SecurityException
- If a security manager exists and its
method does not permit the named directory to be createSecurityManager.checkWrite(java.lang.String)
- 为这个抽象目录创建目录结构。创建成功返回true,否则返回false。
- 抛出安全异常
-
-
-
mkdirs
public boolean mkdirs()
Creates the directory named by this abstract pathname, including any necessary but nonexistent parent directories. Note that if this operation fails it may have succeeded in creating some of the necessary parent directories.-
Returns:
-
true
if and only if the directory was created, along with all necessary parent directories;false
otherwise
Throws:
-
SecurityException
- If a security manager exists and its
method does not permit verification of the existence of the named directory and all necessary parent directories; or if theSecurityManager.checkRead(java.lang.String)
method does not permit the named directory and all necessary parent directories to be createdSecurityManager.checkWrite(java.lang.String)
- 根据抽象路径名 创建目录结构,包括必要但是不存在的父目录。请注意,如果操作失败,但它可能成功的创建了一些必要的父目录。
- 如果目录被创建成功返回true,否则返回false。
-
- 也就是意味着当目录结构不存在的时候 ”mkdir“ 是不能创建目录结构的,而 “mkdirs” 是可以帮助你创建不存在的目录结构的。但是有个缺点,如果程序报错终止,mkdirs有可能已经为你创建了目录结构。
-