I have a csv file. I am reading each line from this and writing to another file. I am doing it using StringTokenizer. My problem is: I wanted to count no of tokens in a string. IF number of tokens in a particular row is less than 19, some error message has to be displayed. I thought of using String.split() but, i am not sure, like which class i should import to do the same.
Can any one guide me in this regard!
thanks in advance
With Regards,
Anu
Jeff Albertson
Ranch Hand
Joined: Sep 16, 2005
Posts: 1780
posted
0
You said you are using StringTokenizer. Does it have any method to count tokens? StringTokenizer's API page contains this instruction:
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.
Have you investigated String's split method? Have you checked out package java.util.regex? I suggest you do these three things, in that order.
There is no emoticon for what I am feeling!
Anu satya
Ranch Hand
Joined: Mar 17, 2005
Posts: 146
posted
0
Thanks Jeff.
I got the solution.
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to
run our stuff on 16 servers instead of 3.