在文本文件中查找字符串的方法。然后将以下行提升到一定限度
这就是我到目前为止所拥有的:
public String[] findStudentInfo(String studentNumber) {
Student student = new Student();
Scanner scanner = new Scanner("Student.txt");
// Find the line that contains student Id
// If not found keep on going through the file
// If it finds it stop
// Call parseStudentInfoFromLine get the number of courses
// Create an array (lines) of size of the number of courses plus one
// assign the line that the student Id was found to the first index value of the array
//assign each next line to the following index of the array up to the amount of classes - 1
// return string array
}
我知道如何查找文件是否包含我试图查找的字符串,但我不知道如何检索其所在的整行。
这是我第一次发帖,所以如果我做错了什么,请让我知道。