I am trying to count the occurrence of every letter of the alphabet when reading from a txt file. So far my code just counts the letter a - successfully tho.
int counter = 0;
    try (BufferedReader reader = new BufferedReader(new FileReader(file))) {
        int ch;
        for (char a : "ABCDEFGHIJKLMNOPQRSTUVWXYZ".toCharArray()) {
            char toSearch = a;
            counter = 0;
            while ((ch = reader.read()) != -1) {
                if (a == Character.toUpperCase((char) ch)) {
                    counter++;
                }
            }
            System.out.println(toSearch + " occurs " + counter);
        }
How do I make it work, that all letters are counted for? }
 
     
     
    