Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Object Serialization
Index -> Programming, Java -> Java Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Dreamcite




PostPosted: Fri Dec 19, 2008 9:23 pm   Post subject: Object Serialization

Hi Everyone.

I have a problem where objects cannot be read using ObjectInputStream. I have a pretty good idea on what the error is caused by, but I'd like to make sure and also figure out how to overcome the problem.

I don't have any sample codes but an example should suffice.

I make an application that takes orders from customers and serializes objects containing relevant information to a file. Once I close the output stream (which I assume it does automatically when the application is closed) opening any additional streams to that file will cause a StreamCorruptedException when reading from it again. I think the error is caused because ObjectOutputStream writes a header in it's constructor, so the file will have several headers and ObjectInputStream only expects a single header.

So is there anyway I can keep writing objects to a single file and retrieve them properly?
Sponsor
Sponsor
Sponsor
sponsor
HellblazerX




PostPosted: Fri Dec 19, 2008 9:29 pm   Post subject: RE:Object Serialization

Why not store the information in your own format?
Display posts from previous:   
   Index -> Programming, Java -> Java Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 2 Posts ]
Jump to:   


Style:  
Search: