public static boolean mkdirsWithRetry(final File f){
  if (f.exists()) {
    return f.isDirectory();
  }
  for (int i=0; i < 10 && !f.isDirectory(); ++i) {
    f.mkdirs();
  }
  return f.isDirectory();
}

public static boolean mkdirsWithRetry ( final File f ) { if ( f . exists ( ) ) { return f . isDirectory ( ) ; } for ( int i = 0 ; i < 10 && ! f . isDirectory ( ) ; ++ i ) { f . mkdirs ( ) ; } return f . isDirectory ( ) ; }
a thread - safer mkdirs . mkdirs ( ) will fail if another thread creates one of the directories it means to create before it does . http : / / bugs . sun . com / bugdatabase / view_bug . do ? bug_id = 4742723 this attempts the mkdirs ( ) multiple times , so that if another thread does create one of the directories , the next call to mkdirs ( ) will take that into account . note : this returns true iff the file f ends up being a directory , contrary to mkdirs ( ) , which returns false if it existed before the call .
