Hello I am developing a word game where i want to check the user input as valid word or not please suggest the way i can check the given string in android.
Eg . Str
zeitue said:import java.io.BufferedReader; import java.io.FileReader; import java.io.IOException; class WordChecker { public static boolean check_for_word(String word) { // System.out.println(word); try { BufferedReader in = new BufferedReader(new FileReader( "/usr/share/dict/american-english")); String str; while ((str = in.readLine()) != null) { if (str.indexOf(word) != -1) { return true; } } in.close(); } catch (IOException e) { } return false; } public static void main(String[] args) { System.out.println(check_for_word("hello")); } }
but this will only work on linux. if you want this same thing on a mac change the path from
/usr/share/dict/american-english
to
/usr/share/dict/web2
I have not tried this on windows but if someone knows comment below