Please do not top-post, not even to your own posts.
DL wrote:
Here is a class the does the writing, but i am getting exceptions saying
its not serialized.etc.
I doubt very much that any error message included the word "etc." Are you
certain that you copied and pasted the error messages correctly?
import java.io.*;
public class WriteStudentData {
/** Creates a new instance of WriteStudentData */
public WriteStudentData() {
}
// method will take the student list and save it to student.dat file.
public void save(Student[] student)
{
try {
ObjectOutputStream objOut = new ObjectOutputStream(new
FileOutputStream("student.dat"));
objOut.writeObject(student);
objOut.close();
}
catch (Exception e) {
e.printStackTrace();
}
}
}
Read the Javadocs on java.io.Serializable. It will explain why you cannot use
ObjectOutputStream yet for the Student type.
Incidentally you get better results on newsgroups if you post an SSCCE.
Without the source for the Student class in hand we have to guess (correctly)
why you cannot serialize the class.
BTW, there are other ways to write information to a file than serialization.
--
Lew