I'm not sure what is really desired here. I would say that, literally speaking, to "serialize an object using FileWriter" is impossible (or at least massively backwards). "Serialize" in
Java implies a specific format defined in the
Java Object Serialization Specification - which normally we don't need to think about because ObjectOutputStream and ObjectInputStream take care of it for us. If for some reason you want to replicate this format without using these classes, I suppose it's possible, but a lot of work - and you really need a byte-based OutputStream, not a Writer.
Alternately you might want to develop your own file format which can be used to save and load the state of an object - similar to what serialization does, but not literally serialization. This would take some work also, but you could customize the format to your needs. For example you might want to create a human-readable format to allow people to easily read and modify the files. XML would be a good approach here - you could use a format like this:
This represents a Vector containing two MyClass instances. You'd need to write code to read and write such files, but you can use the existing XML parsing tools to make the job easier.
Is this what you had in mind?
[ November 07, 2002: Message edited by: Jim Yingst ]