Java Serializable Object to Byte Array?

Prepare bytes to send: ByteArrayOutputStream bos = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(bos); out. WriteObject(yourObject); byte yourBytes = bos.toByteArray(); out.close(); bos.close(); Create object from bytes: ByteArrayIntputSream bis = new ByteArrayInputStream(yourBytes); ObjectInput in = new ObjectInputStream(bis); Object o = in.readObject(); bis.close(); in.close().

This isn't a complete answer, it just tells how to transform Serializable class into byte array but the question itself covers the whole topic including RMI, object construction and deconstruction, serialization mechanisms and versions etc. Etc. – Esko May 14 '10 at 18:35 That's not how I read the question.To me it sounds like his problem is how to convert the object to a byte -- not how to send it. – Taylor Leese May 14 '10 at 18:37 Taylor: yes you got it right.

I want to turn the object into a byte and transmit it. Can you please also provide the code regarding how to turn this byte into an object please? – iGuygar May 14 '10 at 18:39 @ikurtz - done.

– Taylor Leese May 14 '10 at 18:41 Taylor: for create object from bytes, I don't see the byte from which the object is being constructed? – iGuygar May 14 '10 at 18:42.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions