【发布时间】:2014-03-19 17:40:44
【问题描述】:
我需要你的帮助!
我在一个 txt 文件中混合了任何信息:
我必须按照下面的规则来打分
- 答对2分;
- -1 分错误答案;
- 未回答问题的分数(带空格)
并根据以下等级对总分进行分类
- 40~36 =>> A
- 35~31 =>> B
- 30~26 =>> C
我的代码是:
private void readRaw() {
tv.append("\n\nDiretório do arquivo processado: res/raw/history_data.txt:\n");
InputStream is = this.getResources()
.openRawResource(R.raw.history_data);
InputStreamReader isr = new InputStreamReader(is);
BufferedReader br = new BufferedReader(isr, 8192);
try {
String test;
while (true) {
test = br.readLine();
// How do I compare the contents of the first line with the contents of the last 20 characters of each line?
if (test == null)
break;
else
tv.append("\n" + " " + test);
}
isr.close();
is.close();
br.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
【问题讨论】: