title: Java File Input/Output. Letter Occurances in a given File
body: <p>my problem is:</p>
  
  <p>Write a program that prompts the user to enter a file name and display the occurrences of each letter in the file. Must use exceptions. Letters are not case-sensitive. </p>
  
  <p><strong>Here is a sample run:</strong> </p>
  
  <pre><code>Enter the File name: example.txt
  
  The Occurrence of A's is 11
  The Occurrence of B's is 2
  ....
  The Occurrence of Y's is 3
  The Occurrence of Z's is 2. 
  </code></pre>
  
  <p>My code was made thinking I had to be case sensitive which I do not have to be. So how do I change my code to include all letters and not just Capital letter. I do not have much time to solve it myself which is why i posted it here: </p>
  
  <pre><code>  import java.io.File;
    import java.io.FileNotFoundException;
    import java.util.Scanner;
  
    public class LetterOccurance
   {
    public static void main(String[] args) {
  
      System.out.print("Enter file name: ");
      File file = new File(new Scanner(System.in).next());
  
      if (!file.exists()) 
      {
          System.out.println(file + " doesn't exist");
          System.exit(1);
      }
      String buffer = "";
      int[] letterCount = new int[26];
      try (Scanner input = new Scanner(file)) 
      {
  
          while (input.hasNext()) 
          {
              buffer = input.nextLine();
              for (char ch : buffer.toCharArray())
              {
                  ch = Character.toUpperCase(ch);
                  if (isLetter(ch)) 
                  {
                      letterCount[ch - 'A']++;
                  }
              }
  
          }
      } 
      catch (FileNotFoundException ex) 
      {
          ex.printStackTrace();
      }
  
      for (int i = 0; i &lt; letterCount.length; i++) 
      {
          System.out.println((char)(i + 'A') + " occurrence = " + letterCount[i]);
      }
  
  }
  
  private static boolean isLetter(char ch) 
  {
  
      return (ch &gt;= 'A' &amp;&amp; ch &lt;= 'Z');
  }
  }
  </code></pre>