• Post Reply Bookmark Topic Watch Topic
  • New Topic

Writing objects to files  RSS feed

 
Pres Brawner
Ranch Hand
Posts: 92
  • Mark post as helpful
  • send pies
  • 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.
 
Jim Bertorelli
Ranch Hand
Posts: 136
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Might be. Make a test program and serialize an array list containing serializables. See if it works
 
Chad McGowan
Ranch Hand
Posts: 265
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That is your problem. You should make all objects in your ArrayList implement Serializable, then it should work.
Chad
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!