The Artima Developer Community
Sponsored Link

Legacy Java Answers Forum
December 2001

Advertisement

Advertisement

This page contains an archived post to the Java Answers Forum made prior to February 25, 2002. If you wish to participate in discussions, please visit the new Artima Forums.

Message:

java.io.StreamCorruptedException: Type code out of range, is -84

Posted by Istvan Bagyura on December 05, 2001 at 6:33 AM

Hi!

I've wrote a class that implements Serializable interface and I have a problem with that.

I can write these serialized objects to a file with ObjectOutputStream,
but I can't read these objects from the file.

The code I write to a file with /it works properly/:

private void kiir( TreeObject to )
throws FileNotFoundException, IOException
{
FileOutputStream fout = new FileOutputStream
( SOURCEFILENAME,true) ;
ObjectOutputStream oout = new ObjectOutputStream(fout) ;

oout.writeObject( to );
oout.flush() ;
oout.close();
}


The code I read from a file with /it doesn't work properly/:

public void list()
throws Exception
{
FileInputStream fin = new FileInputStream( this.SOURCEFILENAME ) ;
ObjectInputStream oin = new ObjectInputStream( fin ) ;

TreeObject to ;

while ( ( to = (TreeObject) oin.readObject() ) != null )
System.out.println( to.toString() );

oin.close() ;
}

What can I do? There is something I don't know?

Thanks All!

B.I.





Replies:

Sponsored Links



Google
  Web Artima.com   
Copyright © 1996-2009 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use - Advertise with Us