problem !! input on GUI to a file
Please help me,,, what i want to do is writing on a text area by keyboard,,, and printing everything on a file,, but the problem is that the file is not empty and containing some text,,, so IT JUST DELETES WHATS ON THE FILE , !!
Code:
submit = new JButton("Submit");
submit.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
PrintWriter pr;
string2 = area2.getText(); //copys everything on text area and puts it on string2
File file = new File("C://Users//Desktop//aaa.txt");
try {
pr = new PrintWriter(file);
pr.print(string2); //it prints on file but after deleting my previous text on file~!!
pr.close();
} catch (FileNotFoundException e1) {
e1.printStackTrace();
}
}
});