public static boolean ensureDirectoryExists(File dir){
  if (isDirectory(dir)) {
    return true;
  }
  return dir.mkdirs();
}

public static boolean ensureDirectoryExists ( File dir ) { if ( isDirectory ( dir ) ) { return true ; } return dir . mkdirs ( ) ; }
ensures the directory exists by creating it and its parents if necessary .
