Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Java > Java and JDK > Pro Java
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Pro Java Expert level Java questions not about a specific book. Please indicate your version.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Pro Java section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old February 20th, 2007, 03:33 AM
Registered User
 
Join Date: May 2005
Location: , , .
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Default Serialization & Deserialization

Hi All,

How to deserialize all the objects stored in a file.?

I am storing random number of objects into a file using ObjectOutputStream and is working file n i also know that using readObjectof ObjectInputStream we can read the object. But the thing is (1)how will i know how many objects are there in the file?
   (2)how to read all the objects which are instances of the same class from the file?

Thanks in advance
jagan

Reply With Quote
  #2 (permalink)  
Old April 24th, 2007, 12:50 AM
Friend of Wrox
 
Join Date: Mar 2007
Location: Hyderabad, A.P., India.
Posts: 373
Thanks: 0
Thanked 1 Time in 1 Post
Default

Hi,

Read an object from the file assign it to an Object class variable and use the getClass() method to get the class name, and compare it with required class name if equal continue your process, else continue reading another object.

Regards,
Rakesh
Reply With Quote
  #3 (permalink)  
Old September 7th, 2007, 11:13 AM
ski ski is offline
Registered User
 
Join Date: Sep 2007
Location: , , .
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi,

I think, you should have all the objects present and it can be object hierarchy as well, and now while deserializing, it will construct the
entire object graph.

There are some questions and answers to serialization and deserialization, I came across

http://www.freewebs.com/java-j2ee-qu...re-Java-1.html

Hope this helps.
Thanks.

Reply With Quote
Reply


Thread Tools
Display Modes

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 Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Serialization and DeSerialization balesh.mind ASP.NET 2.0 Professional 0 September 12th, 2007 06:05 AM
Deserialization of a file Mr. Vage C# 2005 2 July 16th, 2007 09:11 PM
Serialization (beginning & end) freezotic BOOK: Beginning Java 2 1 June 20th, 2007 02:21 PM
Linux & KDE & C++ & QT & MYSQL & Kdevelop Munnnki Linux 0 January 2nd, 2005 05:41 PM



All times are GMT -4. The time now is 11:04 AM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.