View Single Post
Join Date: May 2008
Posts: 6
Reputation: xandres is an unknown quantity at this point 
Solved Threads: 0
xandres xandres is offline Offline
Newbie Poster

Re: Modifying a file.

 
0
  #3
Nov 22nd, 2008
Yes I understand the mechanism about writing/reading objects from a file. But basically this is my problem:
- I have a file that has objects in it.
- I want to write a new object in that file when I run the program, but if I do that "directly" using the writeObject, then the other objects will be lost (overwriting file).
- So what I am doing is copying every object from the file to an array of objects, so there will no lost objects after writing the new one. Then I copy each object from the array to the file. I have the methods to do that (as you can see in my Estudiante class) but I don't know how to call the methods in Main class to perform this actions.

Estudiante.generateBackup(); >> this line is working OK (line 23)
Estudiante.writeBackup(); >> this is causing an error when I compile (line 44):

ERROR: Main.java:51: writeBackup(java.util.ArrayList<Student>) in Estudiante cannot be applied to ()
Estudiante.writeBackup();

Thanks for your reply.
Last edited by xandres; Nov 22nd, 2008 at 5:15 am.
Reply With Quote