i have used the following code to save the text in a textpane into a file

final RTFEditorKit kit = new RTFEditorKit();
OutputStream out = new FileOutputStream(fname);

where jfr is the main frame,jta is the textpane,fname is the filename given by the user,doc is the styled document of the text pane...

my problem is that when i give the filename and click save button the text is stored in the file but the textpane is made empty..why is that happening..??

i think you gave fanme=file.txt..

or user may type it...

you should try fname="c://user//deskto//file.txt" or location that you wish

no yar i tried it but doesnt worked,another problem is that it is working fine if the code

final RTFEditorKit kit = new RTFEditorKit();

is placed at the declaration of textpane,but when i keep there undo for this pane is not working,so i kept in the save function,if i do so the above mentioned error is coming...