Java Directory Create mkdir(File dir, boolean createDirectoryIfNotExisting)

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

Description

mkdir

License

Apache License

Declaration

public static void mkdir(File dir, boolean createDirectoryIfNotExisting) throws IOException 

Method Source Code


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

import java.io.File;
import java.io.IOException;

public class Main {
    public static void mkdir(File dir, boolean createDirectoryIfNotExisting) throws IOException {
        if (!dir.exists()) {
            if (!createDirectoryIfNotExisting) {
                throw new IOException("The directory " + dir.getAbsolutePath() + " does not exist.");
            }/* w  ww . j  a va 2 s  .  co m*/
            if (!dir.mkdirs()) {
                throw new IOException("Could not create directory " + dir.getAbsolutePath());
            }
        }
        if (!dir.isDirectory()) {
            throw new IOException("File " + dir + " exists and is not a directory. Unable to create directory.");
        }
    }
}

Related

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