I am reading a file and trying to grab some values from the file using string tokenizer
if there are 3 lines in a file
i am using the following code
i want the output to be printed as 2.....but not able to do so
Another bug is that you call nextToken() twice in a row, without checking hasMoreTokens() in between. If a line has only one token, you'll get an exception there, which I suspect is not what you want.
[ January 23, 2008: Message edited by: Peter Chase ]
StringTokenizer is a legacy class that is retained for compatibility reasons although its use is discouraged in new code. It is recommended that anyone seeking this functionality use the split method of String or the java.util.regex package instead.