wood burning stoves 2.0*
The moose likes I/O and Streams and the fly likes Serialization Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » I/O and Streams
Bookmark "Serialization " Watch "Serialization " New topic
Author

Serialization

peria samy
Greenhorn

Joined: Jun 17, 2013
Posts: 6
Here i tried to serialize Dog object that has another object Coller which is not serializable one so that i marked it as transient. but i wanted to serialize only one variable (size)of Coller object. i don't know how to print value of object that is deserialized. i tried but it shows error.



Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41591
    
  55
it shows error.

Which is?


Ping & DNS - my free Android networking tools app
peria samy
Greenhorn

Joined: Jun 17, 2013
Posts: 6
Normally readObject() method is used to deserialize object. but i used defaultReadObject() method to deserialize object.Here is problem to me because i don't know to print the value of an object that is deserialized. I tried using this syntax(Dog d=(Dog)os.defaultReadObject()) Here error occurs.
Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 18753
    
  40

peria samy wrote:Normally readObject() method is used to deserialize object. but i used defaultReadObject() method to deserialize object.Here is problem to me because i don't know to print the value of an object that is deserialized. I tried using this syntax(Dog d=(Dog)os.defaultReadObject()) Here error occurs.



First, can you properly format your code? Your code, as currently written is very difficult to read. Second, while most of us know the source, can you still QuoteYourSources? Thanks.


Anyway, the purpose of defaultReadObject() is to deserialize the object. You can use the object (ie. for printing the values) after you deserialize it. There is no need to have one line that both deserialize and print the object.

Henry


Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
peria samy
Greenhorn

Joined: Jun 17, 2013
Posts: 6
Thank you Henry Wong. i will follow your instruction hereafter. i got the point.
Tony Docherty
Bartender

Joined: Aug 07, 2007
Posts: 2248
    
  47
peria samy wrote:I tried using this syntax(Dog d=(Dog)os.defaultReadObject()) Here error occurs.

You can only deserialize that which you have serialized and you haven't serialized a Dog object.
peria samy
Greenhorn

Joined: Jun 17, 2013
Posts: 6
Tony Docherty wrote:
peria samy wrote:I tried using this syntax(Dog d=(Dog)os.defaultReadObject()) Here error occurs.

You can only deserialize that which you have serialized and you haven't serialized a Dog object.

Hai Tony Docherty actually i stated that "i used this syntax(Dog d=(Dog)os.defaultReadObect())". but my source code does't have that. i want to explian my problem with example that is why i mentioned like that
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Serialization