hi
i am writing a program(gui based),on clicking on a button,the values in the gui are retrieved and stored to a text file.my problem is that when ever i refill the gui form with new values and click the button,the former values in the files are overwritten.How can i stop this because i need to read all the values of the students that registered in a year?.......i have tried the seek method but,am not getting it right.here is my code...
private class ButtonHandler implements ActionListener,Serializable {
public void actionPerformed(ActionEvent e) {
Form1 form1 = new Form1();
String x = "";
File file = new File("client.txt");
/**
try {
RandomAccessFile Rfile = new RandomAccessFile("client.txt","rw");
long n = 10;
Rfile.seek(n);
} catch(FileNotFoundException j){}catch(IOException nb){}
*/
try {
FormLogic logic = new FormLogic();
PrintWriter out = new PrintWriter(new FileWriter(file));
logic.setName(nameText.getText());
String schooldata = (String) boxForSchoolsComboBox.getSelectedItem();
String graduatedata = (String)graduateDegreeProgramComboBox.getSelectedItem();
String statedata = (String) stateComboBox.getSelectedItem();
String addressdata = addressText.getText();
String citydata = cityText.getText();
String statdata = statetext.getText();
String zipcodedata = zipcodeText.getText();
String countrycode = countryText.getText();
String countrycodedata = countrycodeText.getText();
String areacodedata = areacodeText.getText();
String phonenodata = phonenumberText.getText();
String emaildata = emailaddressText.getText();
String datebatedata = dateofbirthText.getText();
String citizendata =(String) citizenstatusComboBox.getSelectedItem();
boolean radiodata = maleButton.isSelected();
out.println(schooldata);
out.println(graduatedata);
out.println(logic.getName());
out.println(addressdata);
out.println(citydata);
out.println(statdata);
out.println(zipcodedata);
out.println(countrycode);
out.println(countrycodedata);
out.println(areacodedata);
out.println(phonenodata);
out.println(emaildata);
out.println(datebatedata);
if(radiodata == true) {
out.println("MALE");
}
else {out.println("FEMALE");}
out.close();
/**
RandomAccessFile Rfile = new RandomAccessFile("client.txt","rws");
long n =30;
n++;
Rfile.seek(file.length());
Rfile.seek(n);
Rfile.writeBytes(addressdata);
long m =20;
m++;
Rfile.seek(file.lastModified());
Rfile.seek(file.length());
Rfile.writeBytes(citydata);
Rfile.seek(file.length());
Rfile.close();
*/
}catch (IOException e1){
System.out.print("error opening file");
}
//this.launch();
}