Java Directory Create mkdir(File directory)

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

Description

Creates the specified directory.

License

Open Source License

Parameter

Parameter Description
directory a parameter

Exception

Parameter Description
IllegalStateException an exception

Declaration

public static void mkdir(File directory) throws IllegalStateException 

Method Source Code

//package com.java2s;

import java.io.File;

public class Main {
    /**/*www .j  av  a  2  s . co m*/
     * Creates the specified directory. Throws an IllegalStateException if the
     * directory cannot be created.
     * 
     * @param directory
     * @throws IllegalStateException
     */
    public static void mkdir(File directory) throws IllegalStateException {
        if (!directory.exists()) {
            boolean succeeded = directory.mkdirs();
            if (!succeeded) {
                throw new IllegalStateException(
                        String.format("Error while creating directory: %s", directory.getAbsolutePath()));
            }
        }
    }
}

Related

  1. mkDir(File dir)
  2. mkdir(File dir)
  3. mkdir(File dir, boolean createDirectoryIfNotExisting)
  4. mkdir(File directory)
  5. mkdir(File directory)
  6. mkdir(File dirFile)
  7. mkdir(File dirFile)
  8. mkdir(File f)
  9. mkdir(File f)