I simply want to see if a string exists in a dictionary file. (Dictionary file at bottom of question)
I want to check if the voice recognizer can recogn
Read the file using BufferedReader
and store all the words in ArrayList
ArrayList dictionary = new ArrayList<>();
String line;
BufferedReader reader = new BufferedReader(new FileReader(dictionaryFile));
while((line = reader.readLine()) != null) {
if(line.trim().length() <= 0 ) {
continue;
}
String word = line.split(" ")[0].trim();
word = word.replaceAll("[^a-zA-Z]", "");
dictionary.add(word);
}
then check if word present in dictionary
using
dictionary.contains(yourString);
Hope it'll help.