更新时间:2023-02-20 11:05:15
逐行读取文本文件,然后根据该行执行操作.
Read in the text file line by line and then do an action based on that line.
BufferedReader br = new BufferedReader(new FileReader(file));
String line;
while ((line = br.readLine()) != null) {
// process the line.
if (line.equals(". "))
{
// Do something with first line
line = br.readLine()
// Do something with second line
line = br.readLine()
// Split up the third line by space
String split[]= StringUtils.split(line); // split[1] = "Mozart," so you may need to do a little more work there
}
}
br.close();