public static void ensureDirsExistInPath ( String path ) { if ( path == null || path . length ( ) == 0 ) { throw new AssertionError ( "ensureDirsExistInPath called with null or empty path." ) ; } String dirPath = ( path . charAt ( path . length ( ) - 1 ) == File . separatorChar ) ? path . substring ( 0 , path . length ( ) - 1 ) : ( new File ( path ) ) . getParent ( ) ; if ( dirPath == null || knownExistingDirs . contains ( dirPath ) ) { return ; // known to exist } else { ( new File ( dirPath ) ) . mkdirs ( ) ; knownExistingDirs . add ( dirPath ) ; } }
Ensures that the directories in the given path exist creating them if necessary .