我想知道如何將字符串值與.txt文件的每一行進行比較,並獲得相同的值。Android - 將原始文件夾中的.txt文件與字符串進行比較
我從.txt文件獲得所有值,但我不明白如何比較它。 例如
ABC
CBA
CCC
都在我的.txt文件, 和我的活動
String someText = "ABC";
以及如何將其與.txt文件eacline比較。 我在代碼下面做了.txt文件的值。
String result;
try {
Resources res = getResources();
InputStream in_s = res.openRawResource(R.raw.out);
byte[] b = new byte[in_s.available()];
in_s.read(b);
result = new String(b);
tx.setText(result);
} catch (Exception e) {
// e.printStackTrace();
result = "Error: can't show file.";
tx.setText(result);
}