Suppose I have a Map of properties, and I’d like a String representation. toString buys this in the form {key=value, …}. I need to send this data over a wire and reparse it into a Map at the other end. What’s the best way to do this, given that the data might have a comma in it?
Also, is there any other technique that I’m missing entirely? If I could send over the object over the wire itself, that would be a wonderful. I’d like to avoid RMI, though.
Have you considered just using Java Serialization?
If the keys and values in your Map are pretty simple, you should be golden. ObjectOutputStream and ObjectInputStream will help you out.
It’s not incredibly efficient for size and speed, however it’s incredibly fast to implement.
EDIT: By pretty simple, yes I mean implement Serializable. But I also mean that the objects are pretty simple objects. If each object is some sort of a graph or tree, then serialization can get a bit more problematic.