This week's book giveaway is in the Jython/Python forum.
We're giving away four copies of Murach's Python Programming and have Michael Urban and Joel Murach on-line!
See this thread for details.
Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Serialisation to textbased formats  RSS feed

 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hiho
Does exist a possibility to serialize to a textbased format like .ini, config-files or XML-files?
Ciao, J�rgen
 
Matt Senecal
Ranch Hand
Posts: 255
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's easy to serialize objects to files using a FileOutputStream and ObjectOutputStream. Those files look like a lot of gibberish, though, with some text in them. Does your file have to look like a clean text file?
Originally posted by J�rgen Kosche:
Hiho
Does exist a possibility to serialize to a textbased format like .ini, config-files or XML-files?
Ciao, J�rgen

 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, I'm looking for a clean text-file-format. The problem with ObjectOutputStream is, that an change in the classfile does change the format of the serialized file. With an textformat this could be avoided.
 
Matt Senecal
Ranch Hand
Posts: 255
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The only way I've been able to do this in the past is by *not* serializing objects, interpreting the essential data they contain as text, and writing that text to a file. This gives you a clean, formatted text file. When you read the file you create new objects of whatever type they are, and assign them the values specified in the text file.
If you figure out a better way, I'd love to hear it!

Originally posted by J�rgen Kosche:
Yes, I'm looking for a clean text-file-format. The problem with ObjectOutputStream is, that an change in the classfile does change the format of the serialized file. With an textformat this could be avoided.

 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!