Reputation: 11908
FileOutputStream fout = context.getApplicationContext()
.openFileOutput(FILENAME, Context.MODE_PRIVATE);
ObjectOutputStream out = new ObjectOutputStream(fout);
out.writeObject(complexObject);
Will this code work for a complexObject which is an instance of a complex class. By complex I mean that it might contain several arraylists of instances of other classes, many instance variables?
Upvotes: 0
Views: 566
Reputation: 80340
Yes, ObjectOutputStream
can serialize a complex tree of objects as long as all objects in this tree implement Serializable
. It also serializes all java primitive types.
Upvotes: 1