John, If you are on Java 5 (and this isn't a school project), you can use the Scanner class. If not, you'll have to read the lines of the file yourself. Either way, you need to figure out how to express what you want to match in Java.
If you share which approach you plan to take (scanner vs read file), you may get some more concrete advice.
Go through the regular expressions tutorial; you can probably find whether the pattern you are looking for is matched in the file, then whenever it is you can increment your counter.
You might do well to look at the "quantifiers" section; depending on what you are looking for, you might get a different count with a greedy quantifier from a reluctant quantifier.
Other people will doubtless have other ideas about this question.
I'm getting this error when i run it, it compiles fine:
java.util.NoSuchElementException: No line found at java.util.Scanner.nextLine(Scanner.java:1471) at Family.main(Family.java:19) java.util.NoSuchElementException: No line found at java.util.Scanner.nextLine(Scanner.java:1471) at Family.main(Family.java:19) java.util.NoSuchElementException: No line found at java.util.Scanner.nextLine(Scanner.java:1471) at Family.main(Family.java:19)
You can get NosuchElementExceptions if the Scanner tries to read more lines than there are in the text file. Remember there are Scanner methods for reading all sorts of different data types directly from text.
Something must be done about this. Let's start by reading this tiny ad:
Gift giving made easy with the permaculture playing cards