I open file as follows
private static Formatter x;
public static void openFile(){
try{
x=new Formatter("sarit.text");
}
catch(Exception e){
System.out.println("error");
}
}
Here I add a information to the file but the problem of adding the information to this file erases everything that was in the file before inserting the information
public static void addRecords(String age,String city,String name, String password){
x.format(" "+name+" "+password+" "+age+" "+city+"\n");
}
public static void closeFile(){
x.close();
}