I have a large text file I am reading from and I need to find out how many times some words come up. For example, the word the. I\'m doing this line by line e
the
To get the number of occurrence of a specific word use the below code
Pattern pattern = Pattern.compile("Thewordyouwant"); Matcher matcher = pattern.matcher(string); int count = 0; while(matcher.find()) count++;