<p>What is the best way to find the total number of words in a text file in Java? I'm thinking Perl is the best on finding things such as this. If this is true then calling a Perl function from within Java would be the best? What would you have done in condition such as this? Any better ideas?</p>

I'd initialize a
```
word_count
```
int to 1, then loop through each character in the file and increment
```
word_count
```
for every whitespace character
unless
the previous character was a whitespace character. (A space, tab, or newline.)