Hi guys!

I have used a text area to display the contents of a textfile. I am trying to write some code so that when the data is displayed, i can add more data to this file, just by typing in the text area. I have set the setEditable to true, and this lets me edit the data. But the problem is that when i close the text Area which is displayed in a dialogue box, the edited data isn't saved. What can i do?

This is the code i have written:
Java Code:
import java.awt.BorderLayout;
import java.io.DataInputStream;
import java.io.File;
import java.io.FileInputStream;
import javax.swing.JDialog;
import javax.swing.JTextArea;
import java.awt.*;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.awt.event.ActionListener.*;
import java.util.*;
import java.io.*;
import javax.swing.*;
import java.util.Calendar;
import java.awt.image.*;
import javax.imageio.*;
public class notes {
private JTextArea textArea;
public notes() {
JDialog dialog = new JDialog();
dialog.getContentPane().setLayout(new BorderLayout(10, 10));
String record = null;
File file = new File("notes.txt");
FileInputStream fileInput = new FileInputStream(file);
DataInputStream dis = new DataInputStream(fileInput);
BufferedWriter w;
w = new BufferedWriter(new FileWriter("notes.txt"));
String string = dis.readLine();
textArea = new JTextArea();
while(string != null){
textArea.append(string + "\n");
string = dis.readLine();
textArea.setFont(new Font("Times New Roman", Font.BOLD, 14));
dialog.getContentPane().add(BorderLayout.CENTER, textArea);
dialog.setSize(800, 900);
}catch (Exception e){
public static void main(String[] args){
new notes();
Thanks a lot