Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

save an object

 
Nikos Stavros
Ranch Hand
Posts: 243
Python
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
how would I save a rectangle and then load it back into my program
 
Sam Codean
Ranch Hand
Posts: 194
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Search on the Google for ObjectInputStream, ObjectOutputStream, Serialization. You will get code snippets that will write an object to a file and retrives the same.
Hope that helps!!
 
Nikos Stavros
Ranch Hand
Posts: 243
Python
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ok ill look at that thanks
 
Sam Codean
Ranch Hand
Posts: 194
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A Code Snippet that would help



try
{
FileOutputStream out = new
FileOutputStream(System.getProperty("user.home")
+ File.separator
+ "Library"
+ File.separator
+ "Preferences"
+ File.separator
+ "preferences.dat");

ObjectOutputStream obj_out = new ObjectOutputStream(out);
obj_out.writeObject(this);
}
catch(IOException ioe)
{
JOptionPane.showMessageDialog(null,
Util.props.getPreference("Error.txtPreferencesLost"),
"Error",
JOptionPane.ERROR_MESSAGE);
}
 
Nikos Stavros
Ranch Hand
Posts: 243
Python
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ok cheers, ill try that out

thanks for your time
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic