How to make simple dicitonary J2ME
Posted
by batosai_fk
on Stack Overflow
See other posts from Stack Overflow
or by batosai_fk
Published on 2010-06-13T09:20:09Z
Indexed on
2010/06/13
9:22 UTC
Read the original article
Hit count: 191
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.. Add to batosai_fk's Reputation
© Stack Overflow or respective owner