Androidコードに問題があります。静的文字列と一致するようにテキストファイルの各行を読み取るというこのコードの目的も、一致したすべての質問を表示する必要があります。私の静的入力文字列は「あなたの生年月日は何ですか」であり、アセットフォルダにすべての質問があるtext(fms.txt)ファイルもあります。それから私はこのコードをコンパイルしました。エラーのある出力が得られました。
私のコード
try {
ins = this.getAssets().open("fms.txt");
reader = new BufferedReader(new InputStreamReader(ins));
line = reader.readLine();
message = "What is your DOB";
messages = message.split(" ");
int i = 0, j = 0, inc = 1, oldin = 0;
while (line != null) {
lines = line.split("#");
words = lines[0].split(" ");
if (words[0].trim().equals(messages[0].trim())) {
for(i = 1; messages[i].trim() != null; i++) {
Log.e(TAG, "----------::::"+messages[i].trim());
oldin = inc;
}
}
line = reader.readLine();
}
ins.close();
Log.e(TAG, "---------FMSG : "+finalmsg);
} catch(IOException e1) {
e.printStackTrace();
}