import java.io.*;
public class ArraySave implements Serializable{
public ArraySave(){
int[] arrayen = {1, 2, 3};
try{
// Spara objekt i fil
ObjectOutputStream ostream = new ObjectOutputStream(new FileOutputStream("array.dat"));
ostream.writeObject(arrayen);
ostream.flush();
ostream.close();
// Läs objekt från fil
ObjectInputStream instream = new ObjectInputStream(new FileInputStream("array.dat"));
int\[\] indata = (int\[\])instream.readObject();
instream.close();
// Visa vad som lästs in
System.out.println(indata\[0\]+" "+indata\[1\]+" "+indata\[2\]);
}catch(Exception e){System.out.println("Doh! Det funkade inte!");}
}
public static void main(String\[\] args){
new ArraySave();
}
}