• Post Reply Bookmark Topic Watch Topic
  • New Topic

Human Readable and Editable Object Input and Output Streams?  RSS feed

 
Chip Gobs
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • 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

 
maateen ashraf
Ranch Hand
Posts: 122
  • Mark post as helpful
  • send pies
  • 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
  • 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
  • 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
 
Michael Hildner
Ranch Hand
Posts: 297
  • Mark post as helpful
  • send pies
  • 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
  • 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
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!