Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
The moose likes Java in General and the fly likes ClassCastException is occuring. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "ClassCastException is occuring." Watch "ClassCastException is occuring." New topic
Author

ClassCastException is occuring.

Huzefa Zohaib
Ranch Hand

Joined: Nov 21, 2001
Posts: 40
ClassCastException is occuring during execution of the following code.
Please solve this RunTimeError.

I am writing the object to the text file using the following code.
Mani Ram
Ranch Hand

Joined: Mar 11, 2002
Posts: 1140

Are you trying to create an User object and serialize it using the above code?
It won't work this way, because what you are actually creating in the above statement is a String object. So you will get a ClassCastException when you try to cast it into an User object.
Try the following code


Mani
Quaerendo Invenietis
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: ClassCastException is occuring.
 
Similar Threads
Related to Object Serialization
Serialization
serialization question
Serialization and ClassCastExcpetion
how FileOutputStream and ObjectOutputStream working here