John Jai wrote:I tried with the code you posted and got 123 printed... are you sure there is no blank token before that?
Yes I am sure. I am using Eclipse Indigo. Well, that shouldn't affect the output in anyway.
John Jai wrote:Anyways the way you try to print all numbers surrounded by strings in the text file is wrong.
1. Check if scanner has some thing to read using hasNext() in the while condition.
2. Check if the token pointed by the scanner is an integer using hasNextInt() method. Get it using nextInt() and print it. Note that nextInt() moves the scanner to the next position
3. If the condition failed for hasNextInt(), you got to move the scanner to the next position... just call the next() method of the scanner.
Thanks, I will try this and post back.
