Java Serializable

Started by
1 comment, last by Concentrate 13 years, 6 months ago
Ok, this is my AnimationSaving class :
public class AnimationFileSaver {    public AnimationFileSaver(String filePath){        this( new File(filePath));    }    public AnimationFileSaver(File file){        //save file        try{ _tryToSave(file);}        catch(java.io.IOException e){            e.printStackTrace();        }    }    private void _tryToSave(File file)throws java.io.IOException{        java.io.FileOutputStream stream = new java.io.FileOutputStream(file);        java.io.ObjectOutputStream outputStream = new java.io.ObjectOutputStream(stream);        //save data into file        outputStream.writeObject(animationeditor.Controller.AnimationMainController.windowController);        outputStream.writeObject(animationeditor.Controller.AnimationMainController.frameController);    }}


and my loader class
public class AnimationFileLoader {    public AnimationFileLoader(String filePath){        this( new File(filePath));    }    public AnimationFileLoader(File file){        //save file        try{ _tryToSave(file);}        catch(java.lang.Exception e){            e.printStackTrace();        }    }    private void _tryToSave(java.io.File file)throws java.io.IOException, java.lang.ClassNotFoundException{        java.io.FileInputStream stream = new java.io.FileInputStream(file);        java.io.ObjectInputStream inputStream = new java.io.ObjectInputStream(stream);        //save data into file        AnimationMainController.windowController = (AnimationWindowController)inputStream.readObject();        AnimationMainController.frameController = (OnionSkinningController) inputStream.readObject();    }}


The windowController contains the main app window, and the frame controller
has a list of frames used in th program. The above class works partially, but
not fully. The objects that were saved are loaded into the screen, but they
loose their capability of interactions with the user. More over, when I debug
it, my container that holds a list of shapes seems to be empty, but the screen
still shows the shape. Is there something more I should know about java.io.Serializable ? I could show more code, if I need to. Thanks.
Edge cases will show your design flaws in your code!
Visit my site
Visit my FaceBook
Visit my github
Advertisement
None of these classes seem to implement Serializable.

Also, none of that _underscoreNaming. Java has fixed naming convention, there is no reason to deviate from that.
Does the saver and loader need to implement serializable? And I'm not sure whats the convention in java. Just regular naming I guess.

These classes implements java.io.Serializable
AnimationMainController.windowController;        AnimationMainController.frameController


Edge cases will show your design flaws in your code!
Visit my site
Visit my FaceBook
Visit my github

This topic is closed to new replies.

Advertisement