So I'm using the following code below to serialize my arraylist of obejcts. it is work except that I want to be able to specify where it outputs the file.
I thought I could change:
FileOutputStream fout = new FileOutputStream("AccList.dat");
to something like:
FileOutputStream fout = new FileOutputStream("C:\Program Files\test\AccList.dat");
but then it just crashes. I kind of understand that its just declaring FileOutputStream as AccList.dat I think... But how do I specify a save location?
says:
Exception in thread "main" java.lang.Error: Unresolved compilation problem:
Invalid escape sequence (valid ones are \b \t \n \f \r \" \' \\ )
public void SaveArray() { /* serialize arraylist */ try { System.out.println("serializing list"); FileOutputStream fout = new FileOutputStream("AccList.dat"); ObjectOutputStream oos = new ObjectOutputStream(fout); oos.writeObject(AAL.accArray); oos.close(); } catch (Exception e) { e.printStackTrace(); } }// end SaveArray