Java Create Directory mkdir(String dir)

Here you can find the source of mkdir(String dir)

Description

Create a directory, if it does not exist.

License

Open Source License

Declaration

public static boolean mkdir(String dir) 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import java.io.*;

public class Main {
    /**/*from   w  w  w . j  av  a2s .  com*/
     * Create a directory, if it does not exist.
     */
    public static boolean mkdir(String dir) {
        if (!exists(dir)) {
            return (new File(dir)).mkdirs();
        } else {
            return isDirectory(dir);
        }
    }

    /**
     * Check if a file exists.
     */
    public static boolean exists(String file) {
        return (new File(file)).exists();
    }

    /**
     * Check if the argument is a directory.
     */
    public static boolean isDirectory(String dir) {
        return (new File(dir)).isDirectory();
    }
}

Related

  1. mkdir(final File file)
  2. mkdir(final String directory)
  3. mkDir(final String folderPath)
  4. mkDir(String destDir, String dirName)
  5. mkdir(String dir, String file)
  6. mkdir(String dir_str)
  7. mkdir(String directory)
  8. mkdir(String directory)