I have two Class Objects that implement serializable and I need to be able to read and write them to a single file. The Objects are tutordb and admindb. I want do do this using ObjectOutputStream, ObjectInputStream, FileInputStream, and FileOutputStream.
I have never done this before so could someone help me out here? Or link me to a place where I can look at some examples? This is what i have come up with, i don't know if it is right.
FileOutputStream ostream = new FileOutputStream("cstutor.cst"
;
ObjectOutputStream p = new ObjectOutputStream(ostream);
p.writeObject(Object obj);
p.writeObject(Object obj);
p.flush();
ostream.close();
When the arguments are Object obj do I have to provide an instance of that object or the object itself?
Actually admindb and tutordb are packages, so do I have to write every Object in that package to ObjectOutputStream or just the top level Object? Top level Objects would be UserDB for admindb and TutorialDB for tutordb.
Someone please show me how this works!
I have never done this before so could someone help me out here? Or link me to a place where I can look at some examples? This is what i have come up with, i don't know if it is right.
FileOutputStream ostream = new FileOutputStream("cstutor.cst"
ObjectOutputStream p = new ObjectOutputStream(ostream);
p.writeObject(Object obj);
p.writeObject(Object obj);
p.flush();
ostream.close();
When the arguments are Object obj do I have to provide an instance of that object or the object itself?
Actually admindb and tutordb are packages, so do I have to write every Object in that package to ObjectOutputStream or just the top level Object? Top level Objects would be UserDB for admindb and TutorialDB for tutordb.
Someone please show me how this works!