Java Directory Create mkdir(File dirFile)

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

Description

Create a directory by calling mkdir();

License

Apache License

Parameter

Parameter Description
dirFile a parameter

Declaration

public static void mkdir(File dirFile) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

import java.io.*;

public class Main {
    /**//w  w  w  . j  a va  2s  .  c om
     * Create a directory by calling mkdir();
     * 
     * @param dirFile
     */
    public static void mkdir(File dirFile) {
        System.out.println("Creating the folder: " + dirFile);
        try {
            // File dirFile = new File(mkdirName);
            boolean bFile = dirFile.exists();
            if (bFile == true) {
                System.out.println("The folder exists.");
            } else {
                System.out.println("The folder do not exist,now trying to create a one...");
                bFile = dirFile.mkdir();
                if (bFile == true) {
                    System.out.println("Create successfully!");
                } else {
                    System.out.println("Disable to make the folder,please check the disk is full or not.");
                    System.exit(1);
                }
            }
        } catch (Exception err) {
            System.err.println("ELS - Chart : unexpected error");
            err.printStackTrace();
        }
    }
}

Related

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