-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

> Could anyone give me a pointer on the best way to save the object. (my
> research showed that serialization is slow but some people cannot be
> convinced  and are still wanting it done :/  )
> 

Here's an example of (de)serializing a Public key object:

byte[] encode(PublicKey key) throws Exception {
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        ObjectOutputStream oos = new ObjectOutputStream(baos);
                
        oos.writeObject(key);
        oos.flush();
                
        return baos.toByteArray();
}

PublicKey decode(byte[] bytes) {
        ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
        ObjectInputStream ois = new ObjectInputStream(bais);
        PublicKey key = (PublicKey)ois.readObject();
        
        return key;
}

cheers,
- --
ᛏᚠᛖᚾᚱᛁᛊᚢᛚᚠᚱᛏ
ᛏᚢᛚᚠᛊᛚᛖᛁᚠᚨᚱᛏ
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAkj01FoACgkQNig/07RbnEvv8QCfXysIdln3LsL99Ist0A4yIeoH
MdsAnA3SRqmwyNSda6hipGrDSQhV9ZK5
=Z/Ci
-----END PGP SIGNATURE-----

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to