Question: java - help me serialize. i am trying to serialize but it keeps showing the following errors: Exception in thread main java.io.NotSerializableException: DataSystem at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1184)

java - help me serialize.

i am trying to serialize but it keeps showing the following errors:

Exception in thread "main" java.io.NotSerializableException: DataSystem

at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1184)

at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:348)

at Test.main(Test.java:21)

this is my code: (all the classes except DataSystem implement serilizable)

what is wrong with it?

public static void main(String []args) throws IOException{

DataSystem one = new DataSystem();

one.map.put("Bbarley", new Student("Bbarley", new ArrayList()));

FileOutputStream file = new FileOutputStream("storage.ser");

ObjectOutputStream outStream = new ObjectOutputStream(file);

// the following line will save the object in the file

outStream.writeObject(one);

outStream.close();

}

}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!