Re: EOs and NSData

Ben Trumbull <[email protected]> Wed, 4 Jun 2003 17:30:03 -0700
Newsgroups gmane.comp.web.webobjects.eof,gmane.comp.web.webobjects.devel
Message-ID <a05200f01bb043e3de047@[17.205.42.108]>
At 19:03 -0500 6/4/03, Ricardo Strausz wrote:
>Is there a simple way to encapsulate all instance variables of an eo 
>into a single nsdata object?
>

Uhm... why ?

EOs implement Serializable.  So ...

ByteArrayOutputStream bstream = new ByteArrayOutputStream(1024);
ObjectOutputStream p = new ObjectOutputStream(bstream);

p.writeObject(myEO);
p.flush();

byte[] bytes = bstream.toByteArray();
NSData result = new NSData(bytes);
-- 

-Ben