Java Utililty Methods Directory Create

List of utility methods to do Directory Create

Description

The list of methods to do Directory Create are organized into topic(s).

Method

Filemkdirs(File dir)
mkdirs
if (!dir.exists()) {
    dir.mkdirs();
return dir;
booleanmkdirs(File dir)
Just a simple wrapper around `java.util.File.mkdirs()` that fails when trying to create a folder named "~"
String path = dir.getPath().replace('\\', '/');
if (path.equals("~") || path.startsWith("~/") || path.contains("/~/")) {
    return false;
return dir.mkdirs();
Filemkdirs(File dir)
mkdirs
if (dir == null)
    return null;
if (!dir.exists() && !dir.mkdirs())
    throw new RuntimeException("ERROR: mkdirs: " + dir);
return dir;
booleanmkdirs(File directory)
Creates a new directory.
if (directory.exists())
    return false;
if (!directory.mkdirs())
    throw new IOException("cannot create the directory: " + directory);
return true;
voidmkdirs(File directory)
Method description
if (!directory.exists() && !directory.mkdirs()) {
    throw new IllegalStateException("could not create directory ".concat(directory.getPath()));
booleanmkdirs(File directory)
mkdirs
if (directory == null) {
    return false;
if (directory.exists()) {
    return false;
if (directory.mkdir()) {
    return true;
...
Filemkdirs(File directory, String string)
mkdirs
File path = new File(directory, string);
mkdirs(path);
return path;
voidmkdirs(File dirs)
CreatingUtils all folders at once.
if (dirs.exists()) {
    if (dirs.isDirectory() == false) {
        throw new IOException("Directory '" + "' is not a directory.");
    return;
if (dirs.mkdirs() == false) {
    throw new IOException("Unable to create directory '" + dirs + "'.");
...
booleanmkdirs(File dumpFile)
mkdirs
File dir = dumpFile.getParentFile();
return dir.exists() || dir.mkdirs();
voidmkdirs(File f)
A hopefully more robust to concurrent creation mkdirs method: http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4742723
if (f.mkdir() || f.exists()) {
    return;
File canonFile;
try {
    canonFile = f.getCanonicalFile();
} catch (IOException e) {
    return;
...