String Tokenizer Question
I know String Tokenizer is not the best way to solve this problem but i have to use it. Basically how do i setup the tokenizer to Extract all letters seperately.
So given the string "xyz|[" i need to get the tokens:
"x","y","z","|","[". Just wondering how to do this, and if i even can do this by just setting up a certain delimeter. Thanks.
I think the best approach is using String.toCharArray() and u will get a Character array. or use charAt() instead of StringTokenizer.
I don't understand why you are compelled to use StringTokenizer.
yeah its just for an assignment, but im using charAt now, will ask prof why he tells us to use Tokenizer, thanks.
I don't understand it, either. There is no "delimiter" to tokenize the string ... not even white space. How can you "split" the string ... I think sudheerprem's and your approach with charAt is the best way to address this problem.
I had to do something similar and I used the split method.
I had to read all the lines from a file and count the number of occurrences of each letter.
Hopefullt this will be of use to you as I found it a nightmare to do
while((textLine = MyFile.readLine()) !=null)
//Create an array to hold each of the words
//Remove any whitespace character (tab, new line, form feed,
//end of line, carriage return)
String numWords = newLine.split("\\s");
AdRock: why wouldn't charAt do the same thing? Just iterate up the string, take charAt.
The problem which p1kn1c is dealing with is the assignment calls for him to use StringTokenizer.
By airrazor in forum Java
Last Post: 11-06-2005, 11:18 AM
Last Post: 09-09-2005, 12:17 PM
By mdengler in forum ASP.NET
Last Post: 11-26-2002, 03:32 PM
By Rob Teixeira in forum .NET
Last Post: 05-31-2002, 04:30 PM
By Kunal Sharma in forum VB Classic
Last Post: 04-25-2000, 04:45 PM
-- Android Development Center
-- Cloud Development Project Center
-- HTML5 Development Center
-- Windows Mobile Development Center