ho scritto questo codice:
FileOutputStream f = null;
try
{
f = new FileOutputStream("lista.dat");
}
catch (IOException e3)
{
System.exit(1);
}
ObjectOutputStream os = null;
Couple c = new Couple();
c.setFirst(new String (fcognome));
c.setSecond(new Integer(matric));
try
{
os = new ObjectOutputStream(f);
os.writeObject(c);
os.flush();
os.close();
}
catch(IOException e3)
{
System.exit(2);
}
FileInputStream fin = null;
ObjectInputStream is = null;
try
{
fin = new FileInputStream("lista.dat");
is = new ObjectInputStream(fin);
}
catch(IOException e3)
{
System.exit(3);
}
Couple c2 = null;
try
{
c2 = (Couple)(is.readObject());
is.close();
}
catch(IOException e3)
{
System.exit(4);
}
catch(ClassNotFoundException e3)
{
System.exit(5);
}
System.out.println(c2.getFirst());
System.out.println(c2.getSecond());
}
ma cosi' mi fa vedere solo i dati immessi l'ultima volta, mentre io vorrei che me li faccesse vedere sempre tutti.
Mi sapreste dire come fare?
grazie!

Rispondi quotando