kadar aşağıdaki satırları alma Yani bu şu ana kadar ne var:Metin dosyasının içindeki dizeyi bulma yöntemi. Sonra belli bir limitin
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
}
Bir dosya ı bulmaya çalışıyorum dize içeriyorsa nasıl bulacağını biliyorum ama bilmiyorum tüm satırın nasıl alınacağı.
Bu benim ilk kez gönderme yaptığım için Yanlış bir şey yapsaydım lütfen bana bildirin.
File file = new File("Student.txt");
try {
Scanner scanner = new Scanner(file);
//now read the file line by line...
int lineNum = 0;
while (scanner.hasNextLine()) {
String line = scanner.nextLine();
lineNum++;
if(<some condition is met for the line>) {
System.out.println("ho hum, i found it on line " +lineNum);
}
}
} catch(FileNotFoundException e) {
//handle this
}
bu ödev ise, örneğin etiketlenmiş edilmelidir: Burada –
Giriş dosyasının bir örneğini ekleyebilir misiniz? – RonK