• 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
  • Ron McLeod
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

Writing objects to files

 
Ranch Hand
Posts: 92
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This is what I tried:
FileOutputStream fos = new FileOutPutStream(some.txt);
ObjectOutputStream oos = new ObjectOutputStream(fos);
oos.writeObject(ArrayListThingy);
Didn't work.
Now writeObject requires that what it writes are Serializable. ArrayLists are Serializable. However, the objects inside the ArrayList are not. Is that what's screwing me up?
Thanks all.
 
Ranch Hand
Posts: 136
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Might be. Make a test program and serialize an array list containing serializables. See if it works
 
Ranch Hand
Posts: 265
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
That is your problem. You should make all objects in your ArrayList implement Serializable, then it should work.
Chad
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic