QUOTE(NickDMax @ 17 Sep, 2007 - 11:26 AM)

I have a class XMLMessage that is pretty simple. It holds a private StringWriter to build up a XML message. Now I am assuming that since StringWriter is not Serializable that it will not be serialized with my object so I will need to customize the read/writeObject functions to capture the StringWriter variable. I am not however looking forward to writing these functions (lets face it, it just doesn't seems fun and besides the XMLMessage's whole purpose was to write XML messages like the kind I would use to encode an object in the writeObject function. It seems silly to instantiate another copy of the vary object that is being serialized just to serialize it).
The XMLMessage is serializable so that it can be part of another object that is serializable... its all very confusing and I would like to be able to test things out to help me find my way.
So, what you're looking for is a way to serialize and de-serialize to test? I would just serialize your object to a binary file and then de-serialize it back into a class. So, something like a FileOutputStream and FileInputStream wrapped by a ObjectOutputStream and ObjectInputStream (respectively). Or were you looking for something else?
Something you might consider is having another String variable that you can use to transfer the value of the StringWriter to before serialization (Strings are serializable). That should be relatively painless. Also, you will have to mark your StringWriter as transient or you'll get an exception.
This post has been edited by Programmist: 17 Sep, 2007 - 10:46 AM