Re: HashMap Conversion
On 11 Nov, 20:53, Arne Vajh=F8j <a...@vajhoej.dk> wrote:
andrewzzz wrote:
On 11 Nov, 20:39, Arne Vajh=F8j <a...@vajhoej.dk> wrote:
andrewzzz wrote:
how do i convert an hash map into a byte array(being able to restore
this later , without losing data)?Serialization !
can you send me link where to find out how? private static byte[] s=
erialize(Object o) throws IOException {
ByteArrayOutputStream ba = new ByteArrayOutputStream(1000);
ObjectOutputStream oba = new ObjectOutputStream(ba);
oba.writeObject(o);
return ba.toByteArray();
}
private static Object deserialize(byte[] b) throws IOException,
ClassNotFoundException {
ByteArrayInputStream ba = new ByteArrayInputStream(b);
ObjectInputStream oba = new ObjectInputStream(ba);
return oba.readObject();
}
All objects need to be serializable for this to work though !
Arne
thanks so much! I will try now!