javaalgorithmstringjava-me

How do I split strings in J2ME?


How do I split strings in J2ME in an effective way?

There is a StringTokenizer or String.split(String regex) in the standard edition (J2SE), but they are absent in the micro edition (J2ME, MIDP).


Solution

  • There are a few implementations of a StringTokenizer class for J2ME. This one by Ostermiller will most likely include the functionality you need

    See also this page on Mobile Programming Pit Stop for some modifications and the following example:

    String firstToken;
    StringTokenizer tok;
    
    tok = new StringTokenizer("some|random|data","|");
    firstToken= tok.nextToken();