Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Java > Java and JDK > BOOK: Beginning Java 2
|
BOOK: Beginning Java 2
This is the forum to discuss the Wrox book Beginning Java 2, SDK 1.4 Edition by Ivor Horton; ISBN: 9780764543654
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning Java 2 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old March 15th, 2004, 03:35 PM
Authorized User
 
Join Date: Sep 2003
Posts: 98
Thanks: 0
Thanked 0 Times in 0 Posts
Default Serialization (beginning & end)

I noticed that every file containing serialized objects begins with a stream header.

From Ivor Horton's JDK 1.3 ed. chapter 9, exercise 5, the code of my Person object file looks like:

¬í sr SerialNames$Personh¦ù¡ýÇ„· L firstNamet Ljava/lang/String;L surnameq ~ xpt Tomt Bartlettsq ~ t Timt Briggssq ~ t Markt Burdettsq ~ t Robertt Changsq ~ t Pault Coopersq ~ t Andrewt Criddlesq ~ t Williamt Fallonsq ~ t Ivort Hortonsq ~ t Davidt Hudsonsq ~ t Jonathant Jonessq ~ t Laurentt Lafonsq ~ t Jimt MacIntoshsq ~ t Christ Morrissq ~ t Chandimat Nethisinghesq ~ t Ront Phillipssq ~ t Robert FEt Shawsq ~ t Gavint Smythsq ~ t Johnt Timneysq ~ t Andrewt Traceysq ~ t Davidt Whitney

I typed the names in at the prompt, a few persons at a time, running main() more than once. First the existing file was restored in an array. Then each time I input a person, the array expanded to put the person alphabetically in place. Finally the whole array was stored in the file. This exercise gave me a lot of hard work!

MY QUESTION IS:
Suppose I want to add another Person object (Zappa, Frank) to the END of the file, without re-storing the existing ones, is this possible?
I gave it a try, but did not succeed. Perhaps the stream header gets in the way, so that the added objects cannot be read?

ANOTHER QUESTION:
Finding the end of the serialized file was a serious problem. I had to catch an EOFException, while I thought the OptionalDataException was meant for that. Still not very elegant! How come?

Greetings
Francis (I use the SDK1.4 API)
 
Old June 20th, 2007, 01:21 PM
Registered User
 
Join Date: Sep 2004
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Default

FYKI,No binary files can be edited in a text editor.





Similar Threads
Thread Thread Starter Forum Replies Last Post
Serialization & Deserialization kadimijagan Pro Java 2 September 7th, 2007 10:13 AM
Ms Access front End with Oracle 10g Back End rahul123 Oracle 1 July 9th, 2007 01:03 AM
Oracle back-end MS-Access 2003 client front-end Corey Access 2 February 16th, 2007 08:31 AM
Oracle Back End - MS Access Front End - Multi User ckaliveas Oracle 1 February 1st, 2007 06:00 AM
beginning wap wml & wmlscript help!! lu_pp Wrox Book Feedback 3 April 12th, 2004 09:23 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.