Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Java > Java and JDK > Pro Java
| 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 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 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

Old April 23rd, 2007, 11:50 PM
Friend of Wrox
Join Date: Mar 2007
Location: Hyderabad, A.P., India.
Posts: 373
Thanks: 0
Thanked 1 Time in 1 Post


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.

Old September 7th, 2007, 10:13 AM
ski ski is offline
Registered User
Join Date: Sep 2007
Location: , , .
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts


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


Hope this helps.

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

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