public static void mkdirs ( File directory ) throws CreateDirectoryException { if ( directory . exists ( ) ) { // file exists and *is* a directory if ( directory . isDirectory ( ) ) { return ; } // file exists, but is not a directory - delete it if ( ! directory . delete ( ) ) { throw new CreateDirectoryException ( directory . getAbsolutePath ( ) , new FileDeleteException ( directory . getAbsolutePath ( ) ) ) ; } } // doesn't exist. Create one if ( ! directory . mkdirs ( ) && ! directory . isDirectory ( ) ) { throw new CreateDirectoryException ( directory . getAbsolutePath ( ) ) ; } }
Creates the specified directory along with all parent paths if necessary