How to update a .txt or .ser file with Serialization
807603Dec 3 2007 — edited Dec 3 2007I'm working on a project and it requires me to save the informations of Users in a text File. The information includes so many fields so that I decide to use the Object Serialiable to write the information to File.
Actually, if there's a new user register , The program will automatically write the informations( as object ) to a the "User.txt" file.
But the problem is : when I used:
ObjectOutputStream output = new ObjectOutputStream(new FileOutputStream("D:/User.txt"));
output.writeObject(e);
output.flush();
output.close();
The code above is not updated the "User.txt" but create a new "User.txt" file. And all the informations in the "User.txt" will be deleted .
For example: I have User1 and User2 in "User.txt"
But when I used:
output.writeObject(User3);
There's only User3 in "User.txt" file . User1 and User2 are deleted.
So is there any way to handle this, please give me the solutions as soon as possible because it's emergency, next week I'll have my project reported. Deeply appreciate.