Ronald Spina wrote:oos = newObjectOutputStream(fos);
out.writeObject();
Well, no, objects don't have names. You would pass a reference to the object you want to write. Since you already have some of the code, and obviously have an idea of what might be next, why not try it and see?
Note, however, that it will not be a text file. This is a binary format, not intended for human consumption. If you want something human readable (sort of), you could use java.beans.XMLEncoder/XMLDecoder.
If anybody has some examples please forward.
There's sure to be plenty on the web. Search for
java serialization example or
java writeObject example or even
java io tutorial.
And welcome to the Ranch!