commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Wendy Smoak <j...@wendysmoak.com>
Subject Re: [httpclient] Sending serialized object from httpclient to servlet.
Date Tue, 08 Feb 2005 20:04:43 GMT
From: "Sanjeev Tripathi" <sanjeev.tripathi@parago.com>
> I know how to serialize object to file or socket. But How I can
> convert object to bytes so I can use
> byte[] encodedData = Base64.encodeBase64( binaryData );

If you know how to serialize an object to a file, then you know about
OutputStreams-- probably FileOutputStream.  There is also a
ByteArrayOutputStream:
http://java.sun.com/j2se/1.4.2/docs/api/java/io/ByteArrayOutputStream.html

     bos = new ByteArrayOutputStream();
     out = new ObjectOutputStream(bos);
     out.writeObject(myObject);
     byte[] binaryData = bos.toByteArray();

HTH,
-- 
Wendy Smoak


---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org


Mime
View raw message