java - ObjectOutputStream not writing to file -


i'm trying serialize object file following:

// fill test data  arraylist<transaction> transactions = new arraylist<>(); transactions.add(new transaction("internet", "2016-09-20", -28)); transactions.add(new transaction("groceries", "2016-09-20", -26));  //serialize transactions  try { //          file f = new file("transactions.ser"); //          outputstream file = new fileoutputstream(f); //          outputstream buffer = new bufferedoutputstream(file); //          objectoutput output = new objectoutputstream(buffer);      file f = new file("transactions.ser");     fileoutputstream fos = new fileoutputstream(f);     objectoutputstream out = new objectoutputstream(fos);     out.writeobject(transactions);     out.flush();     out.close();      fileinputstream fis = new fileinputstream(f);     objectinputstream in = new objectinputstream(fis);     object o = in.readobject();     system.out.println(o);  }  catch(ioexception e){     system.out.println("ioexception"); }  catch(classnotfoundexception e) {     system.out.println("classnotfoundexception"); } 

..however ioexception being thrown. code commented out manage create file, empty, assume it's not permissions issue? after reading found objectoutputstream won't write file. doing wrong?

verify class transaction implements serializable , may have type exception java.io.notserializableexception

i tried code , error concluded did not implement serializable interface because without not convert objects bytes , write them file

public class transaction implements serializable{...} 

Comments

Popular posts from this blog

unity3d - Rotate an object to face an opposite direction -

angular - Is it possible to get native element for formControl? -

javascript - Why jQuery Select box change event is now working? -