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!

Write to File without destroying previous data

Status
Not open for further replies.

Serpha

Programmer
Aug 6, 2001
3
0
0
GB
Does anyone know how I can write to a file while preserving the data already in that file. I know that one way possible would be to first read in all the data from that file first, then output old and new data together but that would not be desirable in this case as the data file could be very large.

Thanks
 
When you create your FileWriter, set the append flag to true. This means that any data you write is written to the end of the file.

FileWriter myfile = new FileWriter("thefile.txt", true);
^^^^
append flag
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top