Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / February 2006

Tip: Looking for answers? Try searching our database.

Serializing PriorityQueue<type> not working?

Thread view: 
Twisted - 22 Feb 2006 22:18 GMT
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
And yup, it works.


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.