Split text in JME and assign values in an array
java, java-me, lwuit, stringtokenizer
Solution
You have to use a loop that checks if there are more tokens and in the loop gets the next token.
Try this:
StringTokenizer tokenizer = new StringTokenizer("one-two-three", "-");
while (tokenizer.hasMoreTokens()) {
String token = tokenizer.nextToken();
// Do something with variable "token"
}
Problem
I'm trying to create an array in j2me with split text. I'm trying to use the StringTokenizer class from ostermiller.org. However I can't figure out how to assign the tokens into an array. What could be wrong with this code? ``` String[] myToken; StringTokenizer tokenObject; tokenObject = new StringTokenizer("one-two-three","-"); myToken= tokenObject.nextToken(); ```