Discussion Board

Results 1 to 4 of 4
  1. #1
    Registered User
    Join Date
    Aug 2009

    Simple Dictionary MIDlet J2ME

    Hi, I am beginner in JavaME. I'd like to make simple dicitionary. The source data is placed on "data.txt" file in "res" directory. The structure is like this:

    #apple=kind of fruit;
    #spinach=kind of vegetable;

    The flow is so simple. User enters word that he want to search in a text field, e.g "apple", system take the user input, read the "data.txt", search the matched word in it, take corresponding word, and display it to another textfield/textbox.

    I've managed to read whole "data.txt" using this code..

    private String readDataText() {
    InputStream is = getClass().getResourceAsStream("data.txt");
    try {
    StringBuffer sb = new StringBuffer();
    int chr, i=0;
    while ((chr = is.read()) != -1)
    sb.append((char) chr);
    return sb.toString();
    catch (Exception e) {
    return null;

    but I still dont know how to split it, find the matched word with the user input and take corresponding word. Hope somebody willing to share his/her knowledge to help me..

  2. #2
    Super Contributor
    Join Date
    Jun 2003
    Cheshire, UK

    Re: Simple Dictionary MIDlet J2ME

    Welcome to Forum Nokia!!

    Sadly, the designers of CLDC did not see fit to include the StringTokenizer class from Java SE. However, you can write a simple method like:

    public String[] split(String input, char separator) {
        // ...
    using the String methods substring() and indexOf().


  3. #3
    Super Contributor
    Join Date
    Sep 2008
    Noida, U.P.

    Re: Simple Dictionary MIDlet J2ME

    By taking use of indexOf(char) adn subString() you can solve your purpose.


  4. #4
    Registered User
    Join Date
    Oct 2009

    Re: Simple Dictionary MIDlet J2ME

    You can ref to this link below:

    Read the res Text file
    And use the given code for StringTokenizer in J2me and split your resource text in to key value pairs.
    Then you can store these Key,value pairs in of strings in a Hashtable.

    Now take users input and use hashtable.get(key) to get the value of from the hashtable an display.

Similar Threads

  1. Simple MIDlet Signing Question
    By nokiadongle in forum Mobile Java General
    Replies: 3
    Last Post: 2008-10-04, 00:38
  2. Accessing T9 dictionary word list from J2ME app
    By steve_j76 in forum Mobile Java General
    Replies: 3
    Last Post: 2008-03-06, 13:47
  3. How to pause simple animation midlet
    By adamj2 in forum Mobile Java General
    Replies: 0
    Last Post: 2008-02-22, 15:12
  4. Simple MIDlet help...
    By Devil619 in forum Mobile Java Media (Graphics & Sounds)
    Replies: 5
    Last Post: 2006-09-06, 22:51
  5. Freeware german/english dictionary midlet
    By sebflash in forum Mobile Java General
    Replies: 0
    Last Post: 2004-10-17, 19:14

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts