Guest User

Untitled

a guest
Jun 19th, 2018
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.31 KB | None | 0 0
  1.     public void countChar() {
  2.         try {
  3.             x = new Scanner(new File(fileName));
  4.             while(x.hasNext()) {
  5.                 s = x.nextLine();
  6.                 for(int i = 0; i < s.length(); i++) {
  7.                     charCount++;
  8.                 }
  9.             }
  10.         System.out.println("I counted " + charCount + " characters.");
  11.         }
  12.         catch(Exception e) {
  13.             //blah blah
  14.         }
  15.     }
Add Comment
Please, Sign In to add comment