Java Directory Create mkdir(File dir)

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

Description

Creates the given directory.

License

Open Source License

Parameter

Parameter Description
dir the directory to be created.

Exception

Parameter Description
IOException if the file could not be created.

Declaration

public static void mkdir(File dir) throws IOException 

Method Source Code


//package com.java2s;
import java.io.File;

import java.io.IOException;

public class Main {
    /**/*from   ww w.java  2 s  .  co m*/
     * Creates the given directory.
     *
     * @param dir the directory to be created.
     * @throws IOException if the file could not be created.
     * @see File#mkdir()
     */
    public static void mkdir(File dir) throws IOException {
        if (!dir.exists() || !dir.isDirectory()) {
            if (!dir.mkdir()) {
                throw new IOException("Failed to create directory " + dir);
            }
        }
    }
}

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)
  7. mkdir(File dir)
  8. mkDir(File dir)