• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

save an object

 
Ranch Hand
Posts: 243
Python
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
how would I save a rectangle and then load it back into my program
 
Ranch Hand
Posts: 194
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
ok ill look at that thanks
 
Sam Codean
Ranch Hand
Posts: 194
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
ok cheers, ill try that out

thanks for your time
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic