   [java] Ok, Type code out of range, is -84
  java.io.StreamCorruptedException: Type code out of range, is -84Well this is a homework and I am using java.io.Serializable and object streams, the writting of objects is done correctly, but somehow when attempting to read them it only reads one object correctly and then always shows the same "Type code out of range, is -84" exception.import java.io.*;class ArchLibro{ private String nm; public ArchLibro(String nombre) {    nm=nombre; }  public void Adicionar() {    ObjectOutputStream os=null;    try    {   os = new ObjectOutputStream( new FileOutputStream(nm,true));   Libro L=new Libro();   char r='s';   while ((r=='s') || (r=='S'))   {  L.leer();  os.writeObject(L);  System.out.print("Adicionar otro registro?(s/n)");  r=Leer.dato().charAt(0);   }    }    catch(IOException e)    { e.printStackTrace();}    finally    {   if (os!=null)   try   {  os.close();   }   catch(IOException e)   { e.printStackTrace();}    } } public void Listar() {    ObjectInputStream os=null;    try    {   os = new ObjectInputStream( new FileInputStream(nm));   Libro L;   System.out.println("\tcodigo\ttitulo\t\t\tautor\t\tnropags\teditorial");   System.out.println("\t---------------------------------------------------------");   while(true)   {   L=(Libro)(os.readObject());   L.mostrar();   }    }    catch(EOFException e)    { }    catch(StreamCorruptedException e)    { e.printStackTrace(); //always gets this exception }    catch(IOException e)    { e.printStackTrace();}    catch(ClassNotFoundException e)    { e.printStackTrace(); }    finally    {   if (os!=null)   try   {  os.close();   }   catch(IOException e)   { e.printStackTrace(); }    }}Sorry for the member names, the teachers on my college force me to do the stupid thing of mixing spanish words with the java language.This works when I am doing it in the College's comps, but here it simply always throws that exception   
Quote:Original post by VexorianSorry for the member names, the teachers on my college force me to do the stupid thing of mixing spanish words with the java language.Yeha, I too had a teacher who did that.   ;Quote:   while(true)   {   L=(Libro)(os.readObject());   L.mostrar();   }Could this be the problem?  Since the loop runs indefinitely, won't "os" eventually run out of readable objects.   ;  Certainly it.Read objects only if available on the stream, and then print their stats out. Bail out of the loop if where the read() method is contained when it returns and end of stream message (I don't remember if it's -1 or anything else, but it's a condition easy to check out - refer to the API).Son Of Cain   ;  It is not that.EOFException is a child of IOException, It will simply get that Exception if it was the case no matter the while(true).But the exception is a very different one.I actually googled that error and no one seems to have an answer, many posts talking about this error -84 and 0 replies or fixes to that.Well I just trashed the whole ObjectStream usage and made my own  methods for writting and reading records on each object class.   