Java mkdir forceMkdir(File directory)

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

Description

force Mkdir

License

Open Source License

Declaration

public static void forceMkdir(File directory) throws IOException 

Method Source Code

//package com.java2s;

import java.io.File;

import java.io.IOException;

public class Main {
    public static void forceMkdir(File directory) throws IOException {
        if (directory.exists()) {
            if (directory.isFile()) {
                String message = "File " + directory + " exists and is "
                        + "not a directory. Unable to create directory.";
                throw new IOException(message);
            }//from  www . j  a v  a 2  s . c o m
        } else {
            if (false == directory.mkdirs()) {
                String message = "Unable to create directory " + directory;
                throw new IOException(message);
            }
        }
    }
}

Related

  1. forceMkdir(File dir)
  2. forceMkdir(File directory)
  3. forceMkdir(File directory)
  4. forceMkdir(String filePath)
  5. forceMkdirs(File file)