Advertisement
Guest User

Untitled

a guest
Feb 21st, 2018
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.64 KB | None | 0 0
  1. public void countFucker (File f) throws FileNotFoundException, IOException {
  2.  
  3. BufferedReader in = new BufferedReader (new FileReader (f));
  4. System.out.println("Letter Frequency inf file " +f);
  5.  
  6. int nextChar;
  7. char ch = 0;
  8.  
  9. int[] count = new int[26];
  10.  
  11. while ((nextChar = in.read()) != -1) {
  12. ch = Character.toLowerCase(ch);
  13. ch = ((char) nextChar);
  14. if (ch >= 'a' && ch <= 'z')
  15. count[ch - 'a']++;
  16. }
  17.  
  18. for (int i = 0; i < 26; i++) {
  19. System.out.printf("%c %d,", i + 'A', count[i]);
  20.  
  21. }
  22.  
  23.  
  24.  
  25. in.close();
  26.  
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement