kerzner
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
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
If you are using Java 1.5 then there is option to storeToXMl and loadFromXML also
ASKER
Let me try that too - that would be more automatic
You can also have look at XStream for serialization to XML, even with Java 1.4.
ASKER
load() and store() worked, and if I need text-only later on, I'll use the quote escape
Thanks!
Thanks!
ASKER