I have a spot where a PriorityQueue<foo> is serialized to a file. A
FileOutputStream is opened successfully, an ObjectOutputStream created
on it, and the queue is fed to writeObject(). The stream is closed. No
exceptions occur but the 1.3KB file generated is nowhere near big
enough, and won't deserialize later. Inspecting the queue just before
serialization reveals it to be full of the expected items. The type foo
is serializable and really just a glorified struct of mostly primitive
types, plus a String and a URL. I've checked that java.net.URL and
java.util.PriorityQueue are serializable.
Adding a flush() of the object output stream just before closing it
doesn't make any difference.
What's going on?
Twisted - 22 Feb 2006 22:32 GMT
Bah, my bad. I forgot to put "implements Serializable" on the
struct-thingie. It should have produced an exception when the queue was
fed to the object output stream, but for some reason it didn't, or the
IDE didn't tell me about it, or something like that.
It now generates a file about 50 times larger, and hex editing it shows
lots of URL strings inside the file, which is what I expected. Now to
see if it actually deserializes OK. :)
Twisted - 22 Feb 2006 22:44 GMT