Re: HashMap toString, what about the other way?
Lew wrote:
String seems like an incredibly bad choice for object serialization.
Gordon Beaton wrote:
On the other hand, it's not fundamentally different than what
java.util.Properties (isa Hashtable) already does with store()/load()
and storeToXML()/loadFromXML().
Exactly the same, except that Properties assumes everything is a String.
The Properties can be saved to a stream or loaded from a stream.
Each key and its corresponding value in the property list is a string.
String.toString() tends to be readily invertible.
Since the question was asked of a HashMap, one must account for non-invertible
toString() methods from non-String objects.
I suppose you could argue that that is not a /fundamental/ difference, but I'd
beg to differ.
Given certain conventions, one could come up with some sort of Java API for
XML Binding (JAXB) or similar, and use it to map object graphs to an XML
representation.
Hmm, I wonder if that might solve the OP's problem ...
--
Lew