Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   Java (http://www.velocityreviews.com/forums/f30-java.html)
-   -   Serializing PriorityQueue<type> not working? (http://www.velocityreviews.com/forums/t150552-serializing-priorityqueue-type-not-working.html)

Twisted 02-22-2006 10:18 PM

Serializing PriorityQueue<type> not working?
 
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 02-22-2006 10:32 PM

Re: Serializing PriorityQueue<type> not working?
 
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 02-22-2006 10:44 PM

Re: Serializing PriorityQueue<type> not working?
 
And yup, it works.


cloud 10-14-2012 04:46 PM

Hey could you please share Serializable PriorityQueue code somewhere and post a link . I need to use the same.


All times are GMT. The time now is 03:48 AM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.