Java tutorial
//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.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); } } } }