You realise that StringTokenizer is regarded as legacy code and the API advises you against using it in new code? Use a
Scanner to read the input stream and try its next() and nextXXX() and hasNextXXX() methods.
You cannot return one word at a time from a method, because a method only ever returns one thing (or
void). You would have to set up a loop in the calling method and return some signal value, maybe
null, to signify the end of input. Rather iffy design, I think. Maybe easier to add the words to a List<
String> and return the List, which the calling method can investigate to its heart's content.