This week's book giveaway is in the General Computing forum. We're giving away four copies of Arduino in Action and have Martin Evans, Joshua Noble, and Jordan Hochenbaum on-line! See this thread for details.
Dear Friends, I want some help on using the StreamTokenizer. I have to read comma separated data from a file and retrieve the each value for processing. I thought of using the treamTokenizer where I can directly give a Reader as input and start getting the tokens. But I notice that I have no option to specify comma as a delimiter, something that can be done in the String tokenizer, and the nextToken() returns int values. How do I handle these int values to be interpreted as some numbers directly? Also, using a StringTokenizer will not be efficient since I will have to form a new StringTokenizer object for each line that is read (Or is there a way out for this issue? Please let me know). Thanks
the problem with StringTokenizer in such a case is that if one of the fields has no value, ie not even a space between the commas, then you dont get a token for it, so things could get messy. you could use a BufferedReader and read a line at a time, then use indexOf(",") or indexOf(",", int fromIndex) and/or substring()