This code snippet works. Except for one line, which I cannot find the solution to.
public void read(Scanner in)
Pattern p = in.delimiter();
//rewind pointer - how!! ??
wordCount += 1;
charCount += in.next().length();
...it appears, much to my chagrin, that the Scanner class *DOES NOT* have a "rewind" method to set the (stinking) pointer back to the beginning. Because I can't resolve this issue, for a text input stream, I either get a perfect line count, or a perfect character/word count - but not both.
...I must do it this way because the calling class will only give me a Scanner object.
Is there any way at all, to reset the Scanner object's data pointer so that I can get both line counts, *and* char/word counts?
Thanx in advance to anyone who replies...