Warning: Cannot modify header information - headers already sent by (output started at /home/mypapit/mobilepitshit/wp-config.php:319) in /home/mypapit/mobilepitshit/wp-content/plugins/bad-behavior/bad-behavior/screener.inc.php on line 9
Solution: StringTokenizer in J2ME JavaME MIDlets » Mobile Programming Pit Stop
Jun 172007

JavaME is perhaps the most portable way to develop application for mobile and limited devices, however due to compactness and simplicity most of the classes that present on normal Java Virtual Machine are not included in the MIDlet VM.

One of the classes is StringTokenizer which is used to break a string into tokens. I’ve stumbled into this exact problem too when I was developing an application that parses input from a remote server back in 2001. I searched for an alternative and finally settled on modifying Ostermiller StringTokenizer implementation which works perfectly for my purposes.

How to enable StringTokenizer in J2ME ?
To use StringTokenizer in your project, you need to download this class file StringTokenzer, and unzip it in your application source folder.

Then import it into your source code, and use it like a normal Java SE StringTokenizer implementation

import net.mypapit.java.StringTokenizer;
String firstToken;
StringTokenizer tok;

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

That’s it! Happy coding!

Download : J2ME StringTokenizer

Download : StringTokenizer Demo App


  10 Responses to “Solution: StringTokenizer in J2ME JavaME MIDlets”

  1. Solution: StringTokenizer in J2ME JavaME MIDlets Turn your Pocket PC PDA into iPhone with iContact Install J2ME / JavaME Midlet Manager in Pocket PC PDA

  2. Dear sir ,
    i need to DTMF tone generate from the mobile key pad then play..tell some idea
    how to set and generate the DTMF tone from the motorola cell using J2ME
    please reply me

    with regards,

  3. Hi!

    Link to zip file is broken!


  4. Yes, link to zip file is error!
    Please fix it, thanks

  5. the link has been fixed

  6. Hi,
    The download link of StringTokenizer.zip file is broken again. Can you please fix it?


  7. What split the text in array on j2me,because don’t have StringTokenizer?

  8. thanks

  9. It’s just awesome! Thank you so much Sir!!!

  10. I’m extremely pleased to find this website. I need to to thank you for ones time due
    to this fantastic read!! I definitely liked every bit of it and i also have
    you book-marked to check out new information in your blog.

 Leave a Reply



You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

This blog is protected by dr Dave\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\'s Spam Karma 2: 294626 Spams eaten and counting...