Java Utililty Methods Create Directory

List of utility methods to do Create Directory

Description

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

Method

booleanmkdir(String name)
Create the specified directory, including any intermediate directories that do not exist.
File dir = new File(name);
return dir.mkdirs();
voidmkdir(String name)
mkdir
String dir_name = "";
if (name.endsWith(File.separator)) {
    dir_name = name;
} else {
    String s = File.separator;
    if (s.equals("\\")) {
        s = "\\\\";
        name = name.replace("/", "\\");
...
voidmkdir(String name, File dir)
mkdir
if (!dir.exists()) {
    if (!dir.mkdir()) {
        throw new IOException(name + " create fail!");
voidmkdir(String path)
make a new directory
File file = new File(path);
if (!file.exists()) {
    file.mkdirs();
} else {
    System.err.println("File " + path + " exists already!");
voidmkdir(String path)
mkdir
File f = new File(path);
if (!f.exists())
    f.mkdir();
booleanmkDir(String path)
mk Dir
File file = new File(path);
if (file.exists()) {
    if (!file.isDirectory()) {
        throw new RuntimeException("File exists and is not a directory: " + path);
    return true;
return file.mkdirs();
...
Stringmkdir(String s)
Creates the directory s (and any parent directories needed).
try {
    if ((new File(s)).mkdirs())
        return "Created dir: " + s;
    else
        return "Failed to create dir or dir already exists: " + s;
} catch (Exception e) {
    return e.toString();
voidmkdir(String save)
mkdir
if (!new File(save).exists()) {
    if (!new File(save).mkdirs()) {
        throw new RuntimeException("Cannot create directory: " + save);
booleanmkdir(String sFullDirName)
Creates the specified directory and if necessary any parent directories.
return md(sFullDirName);
voidmkDirAndFile(File file)
mk Dir And File
if (file.exists()) {
    return;
if (!file.getParentFile().exists()) {
    mkDir(file.getParentFile());
file.createNewFile();