Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Deleting text from a file

Status
Not open for further replies.

GavinEllis

Programmer
Jun 15, 2002
1
0
0
AU
Gday,

I have a JTextarea called textArea and when i load my program it displays the text from a file called letters.txt
Now when I change any of the text it saves it back to that file, here is my save button function

addButton (toolBar, "Save", new ActionListener()
{ public void actionPerformed(ActionEvent evt)
{ // System.out.println(textArea.getText());
out.print(textArea.getText());
}
});

Now If "Example" comes up in the textArea and I modify it to say "Test". After I click save letters.txt will say "ExameplTest". I would like the textArea to save only whatever is in the textArea. I was just trying to find out if I could delete everything in letters.txt after it has loaded it into the text area. Anyone know the commands?

Gavin
 
When "out" is a RandomAccessFile you can use out.seek(0);
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top