• 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
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

Human Readable and Editable Object Input and Output Streams?

 
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I would like to be able to serialize objects to a human-readable and editable format.
For example the following class
-----------------------------
package com.blah.testing;
public class Test implements java.io.Serializable
{
private String name;
private int countOfSomething;
...
}
-------------------------------

might look like the following when serialized to a file
------------------------------
begin
type=com.blah.testing.Test
begin
type=java.lang.String;
fieldName=name;
fieldValue="John Doe";
end
begin
type=int;
fieldName=countOfSomething;
fieldValue=17;
end
end
------------------------------
Is anyone aware of something like a ObjectInputTextStream or an ObjectOutputTextStream that could read and write objects from and to a nice readable format like the above format?
If not, do you have suggestions on how to write classes to implement the above streams?
Thanks,
Chip

 
Ranch Hand
Posts: 122
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
here comes the idea about the use of
BufferedReader for reading
PrintWriter for writing the text format
 
Chip Gobs
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
A utility that can translate from a file created using
FileOutputStream and ObjectOutputStream into some human readable and editable format would be good enough too.
Of course, it would need to be translated back, too.
Chip
 
Chip Gobs
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

I realized that the human readable format might as well be XML,
in case that rings any bells for anyone.
Chip
 
Ranch Hand
Posts: 297
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
For fun I started to write a class that would take an object and, through reflection, output it to xml. Is this the kind of thing you're needing?
 
Chip Gobs
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes. After I realized that I wanted XML, I looked around some on the web. There appear to be some Java Serialization using XML libraries out in the world. One is called JSX.
What I would really like is if Sun would package something like that as part of the JDK, as XMLObjectOutputStream and XMLObjectInputStream (or something like that).
I would like to be able to use this in commercial code without a whole bunch of disclaimers, etc, so using GNU stuff probably is not going to happen.
Chip
 
I think she's lovely. It's this tiny ad that called her crazy:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic