java - Encoder doesnt creat xml file -
Try
I have an xml file, but it just does not work.
save it and load funcs
public class Presenter implements Observer {public void savegame () FileNotFoundException {Last XMLEncoder encoder = new XMLEncoder (New BufferedOutputStream (new FileOutputStream ( "Model2048State.xml")); Encoder.writeObject (model); Encoder.close (); } Public Game2048Model loadGame () FileNotFoundException {XMLDecoder decoder = throws new XMLDecoder (new FileInputStream ( "model2048State.xml")); Game 2048 model i = (game 2048 model) decoder. Read object (); Decoder.close (); Refund M; }}
setters, getters and D Co is all, of course, are installed in the model class my presenter class also happens a lot .. but it is relevant code thanks
not to be stopped BufferedOutput for this possibility should be:
Final OutStream = New BufferedOutputStream (New FileOutputStream ("model2048State.xml")); Final XMLEncoder encoder = new xmlencoder (outstream); Encoder.writeObject (model); Encoder.close (); OutStream.close ();