Link to home
Start Free TrialLog in
Avatar of kerzner
kerznerFlag for United States of America

asked on

Serialize a HashMap into text?

Hi experts,

I need to store a HashMap as a bunch of bytes, and I could use serialization. But my keys and values are all strings, and in my system text processing is much faster. How could I encode it all into text? I stared by using newline as separator, but then I got into values that have newlines, and it all broke.

Thank you
SOLUTION
Avatar of ksivananth
ksivananth
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of kerzner

ASKER

Let me try...
If you are using Java 1.5 then there is option to storeToXMl and loadFromXML also
Avatar of kerzner

ASKER

Let me try that too - that would be more automatic
Avatar of Steiner
Steiner

You can also have look at XStream for serialization to XML, even with Java 1.4.
Avatar of kerzner

ASKER

load() and store() worked, and if I need text-only later on, I'll use the quote escape
Thanks!