Student.txt
1,Giannis,Oreos,Man
2,Maria,Karra,Woman
3,Maria,Oaka,Woman
После запуска моего кода я беру это:
Student.txt
1,Giannis,Oreos,Man
2,Maria,Karra,Woman
3,Maria,Oaka,Woman,2,3,1,3,4,6
Но я хочу, чтобы при поиске ID=2
перейти на 2-ю строку и поставить цифры, например:
Student.txt
1,Giannis,Oreos,Man
2,Maria,Karra,Woman,2,3,1,3,4,6
3,Maria,Oaka,Woman
Код:
@FXML
TextField ID1,glossa,math,fis,xim,prog,gym;
@FXML
public void UseAddLesson() throws IOException{
Scanner x = new Scanner("src/inware/students.txt");
FileWriter fW = new FileWriter("src/inware/students.txt",true);
BufferedWriter bW = new BufferedWriter(fW);
boolean found= false;
while(!found){
String line = x.nextLine();
if(line.contains(ID1.getText())){
bW.write(","+glossa.getText()+",");
bW.write(math.getText()+",");
bW.write(fis.getText()+",");
bW.write(xim.getText()+",");
bW.write(prog.getText()+",");
bW.write(gym.getText());
System.out.println(line);
found= true;
}
}
bW.close();
fW.close();
x.close();
}