1public static void main(String[] args) throws IOException, ClassNotFoundException {
2 Obj array[] = new Obj[10];
3 for (int i = 0; i < array.length; i++) {
4 array[i] = new Emp(i);
5 }
6 try {
7 ObjectOutputStream fOUT = new ObjectOutputStream(new FileOutputStream("prodotti.dat"));
8 for (int i = 0; i < array.length; i++) {
9 fOUT.writeObject(array[i]);
10 }
11 fOUT.close();
12 } catch (IOException e) {
13 System.out.println("Errore nella scrittura");
14 }
15 ObjectInputStream fIN = new ObjectInputStream(new FileInputStream("prodotti.dat"));
16 while (true) {
17 try {
18 Obj p = (Obj) fIN.readObject();
19 System.out.println(Obj.method());
20 } catch (EOFException e) {
21 break;
22 }
23 }
24}