• Post Reply Bookmark Topic Watch Topic
  • New Topic

ObjectOutputStream??  RSS feed

 
Ranch Hand
Posts: 75
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i wanna ask u that . i have work on it .. let assum that i have make a file
ObjectOutoutStream oos = new ObjectOutoutStream(new FileOutoutStream(file.tes));
that file.tes save an one object like that
String str = {"Mohummad","Ali","Rafiq",...};
now do we save in that file more than two object???
 
Ranch Hand
Posts: 2545
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, you can. It is just a 'write' process. You can write as much as you can.
 
Wanderer
Sheriff
Posts: 18671
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm not sure what was being asked:
"Can we save more than one object using ObjectOutputStream?"
Yes, as Don said - you can keep calling writeObject()as many times as you want, for as many different files as you want, as long as you don't run out of memory or file space.
"Can multiple objects be stored as the result of a single writeObject() call?"
Yes. In this example

the single writeObject() invocation actually stores one String[] array and three String objects. A later a single readObject() will read all four into JVM memory.
[ February 09, 2003: Message edited by: Jim Yingst ]
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!