madhawaseeeee

word#count

Aug 1st, 2015
361
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.37 KB | None | 0 0
  1.     public static int WordLengthCount() throws FileNotFoundException {
  2.         File file = new File("hello.txt");
  3.         Scanner keyboard = new Scanner(new FileInputStream(file));
  4.         int count5 = 0;
  5.  
  6.         while (keyboard.hasNext()) {
  7.             if (keyboard.next().length() == 5) {
  8.                 count5++;
  9.             }
  10.         }
  11.         return count5;
  12.     }
Advertisement
Add Comment
Please, Sign In to add comment