mkdirs() will create the specified directory path completely, where mkdir() will only create the lowest directory if it cannot find the parent directory of the directory it is trying to create.
In other words, mkdir() is similar to mkdir , and mkdirs() is similar to mkdir -p .
For example, imagine that we have an empty /tmp . Following code
new File("/tmp/one/two/three").mkdirs();
will create the following directories:
/tmp/one/tmp/one/two/tmp/one/two/three
Where is this code:
new File("/tmp/one/two/three").mkdir();
would not create any directories - since it would not find /tmp/one/two - and return false .
Dave Webb Mar 22 2018-12-22T00: 00Z
source share