public static boolean deleteFileOrDirectory ( File file ) { if ( file . exists ( ) && file . isDirectory ( ) ) { File [ ] files = file . listFiles ( ) ; if ( files != null ) { for ( File f : files ) { deleteFileOrDirectory ( f ) ; } } } return file . delete ( ) ; }
Deletes the given file or directory . If a directory recursively deletes all sub - directories and files .