Advertisement
Guest User

Untitled

a guest
Jun 25th, 2019
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.50 KB | None | 0 0
  1. public void readDictionary() throws IOException {
  2. try {
  3. File file = new File("English.txt");
  4.  
  5. Scanner input = new Scanner(file);
  6.  
  7.  
  8. int count = 0;
  9. while (input.hasNext()) {
  10. String word = input.next();
  11. System.out.println(word);
  12. count = count + 1;
  13. }
  14. System.out.println("number of words: " + count);
  15. }
  16. catch (Exception e) {
  17. System.out.println("couldn't find file");
  18. // TODO: handle exception
  19. }
  20. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement