Advertisement Jump to content


This topic is now archived and is closed to further replies.


[java] saving object files

This topic is 5829 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

is it possible to save group of class object? like this: i have a class that hold : object position : int x,y object image number : int pic object hp : int hp object float : boolean floAt object visible : boolean visiBle and something that refer to another object : MainObject mainObject and then another class : map size : Dimension dimension link to another map : String warp i want to save a group of these two classes object, and later i can erase the one that i don''t use. plz show me a link for saving & loading file or a code maybe to save these classes i have lack knowledge for IO file thank you

Share this post

Link to post
Share on other sites
If you''re simply looking to save a class file to the hard drive, take a look at serialization:

Serialization allows you to write data from a class file such that you can later reconstruct the object. Here''s an example of how to save an object:

MyClass mclass = new MyClass();

FileOutputStream out = new FileOutputStream("datafile");
ObjectOutputStream str = new ObjectOutputStream(out);

Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

By using, you agree to our community Guidelines, Terms of Use, and Privacy Policy. is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!