public static int recursiveDelete(File file) {
        int answer = 0;
        if (file.isDirectory()) {
            File[] files = file.listFiles();
            if (files != null) {
                for (File child : files) {
                    answer += recursiveDelete(child);
                }
            }
        }
        if (file.delete()) {
            answer += 1;
        }
        return answer;
    }
public static int recursiveDelete ( File file ) { int answer = 0 ; if ( file . isDirectory ( ) ) { File [ ] files = file . listFiles ( ) ; if ( files != null ) { for ( File child : files ) { answer += recursiveDelete ( child ) ; } } } if ( file . delete ( ) ) { answer += 1 ; } return answer ; }
Recursively deletes the given file whether its a file or directory returning the number
of files deleted