public static boolean createOrCleanDirectory ( String directory ) { // if the directory does not exist, create it. if ( ! FileUtils . isDirectoryExists ( directory ) ) { LOG . fine ( "The directory does not exist; creating it." ) ; if ( ! FileUtils . createDirectory ( directory ) ) { LOG . severe ( "Failed to create directory: " + directory ) ; return false ; } } // Cleanup the directory if ( ! FileUtils . cleanDir ( directory ) ) { LOG . severe ( "Failed to clean directory: " + directory ) ; return false ; } return true ; }
Create the directory if it does not exist otherwise clean the directory .