Skip to Main Content

Java APIs

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

java.io.StreamCorruptedException

843810May 15 2008
Hello everyone
(code)
java.io.StreamCorruptedException: invalid type code: AC
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1356)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java:351)
at ContactManagement.readContact(ContactManagement.java:53)
at ContactManagement.main(ContactManagement.java:111)
(code)
This is my error which comes when i try to read from a file which has an ObjectOutputStream attacted to in with append value in the constructor and here is code from which the exception is thrown
process.readContact();
(code)
Best Regards
Baabu
here is code of readContact()
(code) 



public void readContact()
{
Contact obj=new Contact(); 


try{
//ois.reset();
while(true)
{
obj=(Contact) ois.readObject();
System.out.println("The Contact Details are as follow: ");
obj.display();//this is line in readContact
}
}catch(EOFException ex)
{
System.out.println("FileEnd");
return;
}catch(StreamCorruptedException ex)
{
System.out.println("Here");
ex.printStackTrace();
}catch(IOException ex){
ex.printStackTrace();
}catch(ClassNotFoundException ex)
{
ex.printStackTrace();
} 



}//readContact 



(code)
and the streams are opened like this 
(code)
oos=new ObjectOutputStream(new FileOutputStream(fileName,true));
ois=new ObjectInputStream(new FileInputStream(fileName));
(code) 

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jun 12 2008
Added on May 15 2008
0 comments
162 views