Just read this text file and put each word in a List , and you can check if this List contains your word.
You can use Scanner scanner=new Scanner("FileNameWithPath"); to read the file, and you can try the following to add words to the List .
List<String> list=new ArrayList<>(); while(scanner.hasNextLine()){ list.add(scanner.nextLine()); }
Then check if your word is there or not
if(list.contains("yourWord")){ // found. }else{ // not found }
By the way, you can search directly in the file.
while(scanner.hasNextLine()){ if("yourWord".equals(scanner.nextLine().trim())){ // found break; }else{ // not found } }
Ruchira Gayan Ranaweera Dec 06 '13 at 7:22 2013-12-06 07:22
source share