在文本文件中找到特定的单词并将该单词存储在数组列表中

时间:2019-01-25 06:26:33

标签: java

我想在文本文件中找到特定的单词,并将该单词存储在列表数组中。

我不知道如何实现或实现它。

1 个答案:

答案 0 :(得分:0)

基本解决方案:

public ArrayList getWords(String searchWord, String listOfWords){
    ArrayList<String> foundWords = new ArrayList<>();
    if (listOfWords.contains(searchWord)){
        foundWords.add(searchWord);
    }
return foundWords;
}