分类: Java
2013-01-03 15:07:35
mkdirs() will create the specified directory path in its entirety where mkdir() will only create the bottom most directory, failing if it can't find the parent directory of the directory it is trying to create.
In other words mkdir() is like mkdir and mkdirs() is like mkdir -p.
For example, imagine we have an empty /tmp directory. The following code
new File("/tmp/one/two/three").mkdirs();would create the following directories:
Where this code:
new File("/tmp/one/two/three").mkdir();would not create any directories - as it wouldn't find /tmp/one/two - and would return false.