Here you can find the source of ensureDirectoryExist(File dir)
public static void ensureDirectoryExist(File dir) throws IOException
//package com.java2s; import java.io.File; import java.io.IOException; public class Main { public static void ensureDirectoryExist(File dir) throws IOException { if (!dir.exists()) { boolean success = dir.mkdirs(); if (!success) throw new IOException("Cannot create directory"); } else {//w w w. ja v a 2s . co m if (!dir.isDirectory()) throw new IOException(dir.getName() + " is not a directory"); } } }