public static void forceMkdir(File directory) throws IOException {
  if (directory.exists()) {
    if (!directory.isDirectory()) {
      String message="File " + directory + " exists and is "+ "not a directory. Unable to create directory.";
      throw new IOException(message);
    }
  }
 else {
    if (!directory.mkdirs()) {
      if (!directory.isDirectory()) {
        String message="Unable to create directory " + directory;
        throw new IOException(message);
      }
    }
  }
}

public static void forceMkdir ( File directory ) throws IOException { if ( directory . exists ( ) ) { if ( ! directory . isDirectory ( ) ) { String message = "File " + directory + " exists and is " + "not a directory. Unable to create directory." ; throw new IOException ( message ) ; } } else { if ( ! directory . mkdirs ( ) ) { if ( ! directory . isDirectory ( ) ) { String message = "Unable to create directory " + directory ; throw new IOException ( message ) ; } } } }
makes a directory , including any necessary but nonexistent parent directories . if a file already exists with specified name but it is not a directory then an ioexception is thrown . if the directory cannot be created ( or does not already exist ) then an ioexception is thrown .
