Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/212.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 如何从文本文件中搜索文本并将该行添加到arraylist_Android - Fatal编程技术网

Android 如何从文本文件中搜索文本并将该行添加到arraylist

Android 如何从文本文件中搜索文本并将该行添加到arraylist,android,Android,我正在开发一个带有文本文件的应用程序。我想将包含搜索文本的行添加到数组列表中。 如 我在这里 第二行没关系,亲爱的 第三行还不错 如果用户搜索单词“亲爱的”,则包含“亲爱的”的所有行都将添加到arraylist中 我的密码在这里 私有列表getQuotes(){ BufferedReader bufferedReader; block17 : { ArrayList arrayList; IOException iOException;

我正在开发一个带有文本文件的应用程序。我想将包含搜索文本的行添加到数组列表中。 如 我在这里 第二行没关系,亲爱的 第三行还不错

如果用户搜索单词“亲爱的”,则包含“亲爱的”的所有行都将添加到arraylist中

我的密码在这里

私有列表getQuotes(){

    BufferedReader bufferedReader; 
    block17 : { 
        ArrayList arrayList; 
        IOException iOException; 
        block18 : { 
            String string2; 
            arrayList = new ArrayList(); 
            try { 
                bufferedReader = new BufferedReader((Reader)new InputStreamReader(getActivity().getAssets().open("Poetry.jbk"))); 
                

            } 
            catch (Throwable throwable) { 
                bufferedReader = null; 
                break block17; 
            } 

            try
            {
                while ((string2 = bufferedReader.readLine()) != null)
                { 
                    if (string2 != null && string2 != "")
                    { 
                        try
                        { 
                            
                            
                        } 
                        catch (Exception exception)
                        { 
                            exception.printStackTrace(); 
                        } 
                    } 
                    arrayList.add((Object)string2); 
                }
            }
            catch (IOException e)
            {} 
            try
            {
                bufferedReader.close();
            }
            catch (IOException e)
            {} 
            return arrayList; 

        } 
    }

    return null;
}