Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Serializing PriorityQueue<type> not working?

Reply
Thread Tools

Serializing PriorityQueue<type> not working?

 
 
Twisted
Guest
Posts: n/a
 
      02-22-2006
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?

 
Reply With Quote
 
 
 
 
Twisted
Guest
Posts: n/a
 
      02-22-2006
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.

 
Reply With Quote
 
 
 
 
Twisted
Guest
Posts: n/a
 
      02-22-2006
And yup, it works.

 
Reply With Quote
 
cloud cloud is offline
Junior Member
Join Date: Oct 2012
Posts: 1
 
      10-14-2012
Hey could you please share Serializable PriorityQueue code somewhere and post a link . I need to use the same.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Serializing RDF...why not start with the triples? Leeh XML 3 01-08-2007 12:44 PM
Serializing classes from Web Services Russ ASP .Net 1 08-10-2004 01:33 PM
problem de-serializing a dataset MattB ASP .Net 0 04-27-2004 05:47 PM
serializing a class & performance -- advice? Jason Shohet ASP .Net 4 07-29-2003 06:47 PM
Serializing classes derived from dataset Aidan Glendye ASP .Net 1 07-28-2003 02:29 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57