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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Appending to a text file in JSP

Status
Not open for further replies.

idam

Programmer
Nov 1, 2001
5
GB
Can anyone please advise as to the best approach to appending to a text file in JSP? I would like to be able to have a line of text written to a plain text file every time a button (within an HTML online form) was clicked. Though I want to keep adding to this text file, not have it overwritten with new data every time the button is clicked.
Thank you.
 
Hi idam,

If you use FileWriter, there is a constructor FileWriter(String fileName, boolean append). If you set append to true, any writes to the file will be appended and will not overwrite the other data.
There is a method inherited from Writer, write(String str) throws IOException, that will write your data to the specified file.

Hope this isn't too simplistic an answer

David[bugeyed]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top