Java Directory Create mkdir(File dir)

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

Description

CreatingUtils single folders.

License

Open Source License

Declaration

public static void mkdir(File dir) throws IOException 

Method Source Code

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

import java.io.File;

import java.io.IOException;

public class Main {
    /**/*www. jav  a 2 s .  c  o m*/
     * CreatingUtils single folders.
     */
    public static void mkdir(File dir) throws IOException {
        if (dir.exists()) {
            if (dir.isDirectory() == false) {
                throw new IOException("Destination '"
                        + "' is not a directory.");
            }
            return;
        }
        if (!dir.mkdir() && !dir.mkdirs()) {
            throw new IOException("Unable to create directory '" + dir
                    + "'.");
        }
    }

    /**
     * CreatingUtils single folder.
     */
    public static void mkdir(String dir) throws IOException {
        mkdir(new File(dir));
    }

    /**
     * CreatingUtils all folders at once.
     */
    public static void mkdirs(File dirs) throws IOException {
        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
                    + "'.");
        }
    }

    /**
     * CreatingUtils all folders at once.
     */
    public static void mkdirs(String dirs) throws IOException {
        mkdirs(new File(dirs));
    }
}

Related

  1. mkdir(File d)
  2. mkdir(File dir)
  3. mkdir(File dir)
  4. mkDir(File dir)
  5. mkdir(File dir)
  6. mkdir(File dir)