• Post Reply Bookmark Topic Watch Topic
  • New Topic

Serialization: Possiblility about writing to text file  RSS feed

 
Mark O' Sullivan
Ranch Hand
Posts: 160
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi.
I'm currently doing the SCJD and wish to learn as much as I can. Just wondering with the default serialization, is it possible to write an object and read objects to a flat file that contains records of these same objects or does serialization store additional detail? For example, is it possible to write objects using a randomaccessfile instead of writing individual bytes of an objects detail instead?
Thanks.
 
Joe Ess
Bartender
Posts: 9406
12
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In my mind, a flat file is simply a file of data which is not structurally related (as opposed to a database, which has a structure). Serialized data could really be both. It could be a single object or collection of unrelated objects or a data structure with internal and/or external references.
One can serialize objects to XML.
One can open a RandomAccessFile for writing and write serialzied objects as records in that file. Such a file could get hard to navigate unless one had a mechanism to record (either as part of a record or an external index) how big each object is so one could navigate.
A plain text file would be problematic because you may have binary (non-text) data which would require encoding (which XML handles).
 
Mark O' Sullivan
Ranch Hand
Posts: 160
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for your reply. I have a better understanding now.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!