** me **
how about more details on your case? the "best" method usually depends on the particular application/use. does the image/sound come from files? from a stream? Is each instance of the class expected to store separate images? Or can an image be shared between different instances?
gsmd
images come from files, sounds come
from a stream; there's actually a Set
of items some of which may have an
image attached; an image can't be
shared
What methods have you tried?
I guess using the Serializable interface is the way to go. Here's two articles on the topic.
Basically,
- implement the Serializable interface in your class
- mark members which shouldn't be saved in the file as transient (members which contain contextual data like file handles, socket connections ,etc).
you have to customize how your image and sound classes write data using, but implementing:
private void writeObject(ObjectOutputStream out) throws IOException;
private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException;