I have this code that serializes a class to me Contact:
@Override
public void serializar() {
Contacto a= new Contacto();
try {
FileOutputStream fos= new FileOutputStream("contactos.dat");
ObjectOutputStream oos= new ObjectOutputStream(fos);
if(oos != null)
{
oos.writeObject(a);
oos.close();
JOptionPane.showMessageDialog(null, "Contacto guardado");
}
} catch (Exception e) {
JOptionPane.showMessageDialog(null, "Hubo un error en el proceso\n"
+ "Ha ocurrido el siguiente error: \n"+e);
}
}
and this one that deserializa the file:
public void deserializar() {
Contacto a;
try {
File file=new File("contactos.dat");
if(file.exists()) {
FileInputStream fis= new FileInputStream(file);
ObjectInputStream ios= new ObjectInputStream(fis);
if(ios != null){
a= (Contacto) ios.readObject();
ios.close();
}
}
} catch (Exception e) {
JOptionPane.showMessageDialog(null, "Hubo un error en el proceso\n"
+ "Ha ocurrido el siguiente error: \n"+e);
}
}
They are in different classes hence they refer to the class contact in each of them
What I want to know is how I can fill a table with the data generated by the serializer class in the file