public static void deleteRecursively ( File file , FilenameFilter filter ) throws IOException { if ( file == null ) { return ; } // On Unix systems, use operating system command to run faster // If that does not work out, fallback to the Java IO way if ( SystemUtils . IS_OS_UNIX && filter == null ) { try { deleteRecursivelyUsingUnixNative ( file ) ; return ; } catch ( IOException e ) { logger . warn ( "Attempt to delete using native Unix OS command failed for path = {}. " + "Falling back to Java IO way" , file . getAbsolutePath ( ) , e ) ; } } deleteRecursivelyUsingJavaIO ( file , filter ) ; }
Delete a file or directory and its contents recursively . Don t follow directories if they are symlinks .