i have a txt file that contains the data to fill an array list of objects example of object:
public class Student implements Serializable 
{
    protected String name;
    protected int number;
   ...
}
I have already implemented a method to read a text file that has the data necessary to create objects and fill an arraylist example of txt file:
Matt,5
John,9
...
After reading the txt file, and adding another Student to the arraylist, how do i update the txt file with the new Student?
Edit: code that i used to read from txt file
private ArrayList<Student> loadTextFileStudent(String filename) {
        ArrayList<Student> students= new ArrayList();
        
        File f = new File(filename);
        if (f.exists() && f.isFile()) {
            try {
                FileReader fr = new FileReader(f);
                BufferedReader br = new BufferedReader(fr);
                String line;
                while ((line = br.readLine()) != null) {
                    
                    String[] s = line.split(",");
                    if (s.length!=0) {
                        String name;
                        int number;
                        try 
                        {
                            name= s[0];
                            number= Integer.parseInt(s[1]);
                        } catch (NumberFormatException e) {
                            System.out.println("Error");
                            name="";
                            number= 0;
                        }
                        Student temp=new Student(name,number);
                        students.add(temp);
                    }
                }
                br.close();
            } catch (FileNotFoundException ex) {
                System.out.println("Error opening file.");
            } catch (IOException ex) {
                System.out.println("Error reading file.");
            } catch (Exception e) {
                System.out.println("ERROR");
                e.printStackTrace();
            }
        } else {
            System.out.println("File not found.");
        }
        return students;
    }
 
    