Can anyone give me a hand with that?
The idea is to recover all the "Video" objects, which are saved in a file, but apparently I'm only recovering the first object and then I get this error: java.io.StreamCorruptedException: invalid type code: AC.
I leave a part of the method that, in theory, should recover said objcts from the file:
Thank you very much already.
public static void recuperarVideo(Video unVideo) {
try {ObjectInputStream ois = new ObjectInputStream(new
FileInputStream("F:/JAVA Projectos/taller01/Datos/Videos.txt"));
Object aux = ois.readObject();
// Mientras haya objetos
while (aux!=null)
{if (aux instanceof Video)
System.out.println(aux); // Se escribe en pantalla el objeto
aux = ois.readObject();
} ois.close();}
catch (Exception e) {
e.printStackTrace();}}
Method that saves the "video" object:
public static void guardarVideo(Video unVideo) {
try {ObjectOutputStream escribiendoFichero = new ObjectOutputStream(new
FileOutputStream("F:/JAVA Projectos/taller01/Datos/Videos.txt",true));
escribiendoFichero.writeObject(unVideo);
escribiendoFichero.close(); }
catch (EOFException e) { return;}
catch (Exception e) {
e.printStackTrace(); } }