View Single Post
Old 11-12-2012, 04:59 PM   PM User | #3
Fou-Lu
God Emperor


 
Fou-Lu's Avatar
 
Join Date: Sep 2002
Location: Saskatoon, Saskatchewan
Posts: 15,641
Thanks: 4
Thanked 2,448 Times in 2,417 Posts
Fou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to all
Quote:
Originally Posted by OldBlue View Post
This was obviously the wrong forum to post in for timely replies...
Its a long weekend, you can't expect very many people are around :P
FileWriter has five constructors to it:
Code:
public FileWriter(File);
public FileWriter(File, boolean);
public FileWriter(FileDescriptor);
public FileWriter(String);
public FileWriter(String, boolean);
So with the exception of FileDescriptor, providing a boolean as a second argument will flag appending.
An alternative is to write the data files as serialized. The collection is already serialized, so just implement Serializable on the object class within it, and you can just ovewrite the file every time. Useful if things are small, typically for something like configurations, but you never need to worry about appending since it'll always overwrite the entire file (and therefore can accommodate a changing list as well).
Fou-Lu is offline   Reply With Quote