javajava-memidletsunjava-wireless-toolkit

Java WTK cannot use StringTokenizer


Initially, I was trying to parse a String into parts and found split method. Then I realized that I cannot use it, because the compiler does not support most of the functions and methods. I thought I found a solution here which suggests StringTokenizer, but I am still getting cannot find symbol error even though java.util.* is imported. I am using Java WTK 2.5.2 for CLDC. Do I have to write everything from scratch whenever I get an error or is there anything that I missed? I am not familiar with Java, so any answer will be appreciated.

import java.io.*;
import java.util.*;
import javax.microedition.lcdui.*;
import javax.microedition.midlet.*;
import javax.microedition.io.*;
public class Program extends MIDlet implements CommandListener
{
    public Program()
    {
        ...
    }
    public static String[] split(String data, String token)
    {
        StringTokenizer st = new StringTokenizer("this_is_a_test", "_");
        return null;
    }
}
error: cannot find symbol
        StringTokenizer st = new StringTokenizer("this_is_a_test", "_");
        ^
  symbol:   class StringTokenizer
  location: class Program

Solution

  • It looks like most of the general functions and methods cannot be used in micro edition. So, I had to implement my own case-specific function to solve the problem. Here are some useful links that show what can be used:
    Documentation
    Tutorial & Examples