M3 Consulting interview question

How would you go about counting all the different words in a book using Java