How to save text file without overwriting?
I want to save in a text file without overwriting开发者_C百科 the current data. I mean the next data that will be save will go to the new/next line whenever I save and that is my problem, I don't know how to do that.
Could someone help me about this matter?
Here's the code in save() method :
public void save(String filename) throws IOException
{
FileOutputStream fOut = new FileOutputStream(filename);
ObjectOutputStream outSt = new ObjectOutputStream(fOut);
outSt.writeObject(this);
}
Read the docs
public FileOutputStream(File file, boolean append) throws FileNotFoundException Creates a file output stream to write to the file represented by the specified File object. If the second argument is true, then bytes will be written to the end of the file rather than the beginning. A new FileDescriptor object is created to represent this file connection.
精彩评论