Thanks in advance for any reply. Im trying to save an ArrayList of objects to file, but keep getting IOExeption. The code :
public static final String FILE_PATH=""; // is set to blank for tests. It DOES create a file.
public static void saveToFileCl(ArrayList<cliente> al ) {
if (al != null ) {
try {
FileOutputStream file = new FileOutputStream(FILE_PATH+"cliente.dat");
ObjectOutputStream outStream = new ObjectOutputStream(file);
outStream.writeInt(cliente.getAuto_inc()); // works fine
outStream.writeObject(new Date()); // works fine - not needed just for testing!
outStream.writeObject(al); // exception !!!!
outStream.flush();
outStream.close();
} catch (IOException e) {System.out.println("Erro a gravar ficheiro de clientes!\n"+e.getCause());}
catch (Exception e) {System.out.println("Erro a desconhecido ao gravar ficheiro de clientes!\n"+e.getMessage());}
}
}
Does any one can tell me why the exception?
clienteserializable ? Something tell me the stacktrace tell you exactly the same think...