Article View: borland.public.jbuilder.java.api
Article #2212Re: Object to Byte[].
From: Alex Maksakov
Date: Thu, 26 Apr 2001 06:14
Date: Thu, 26 Apr 2001 06:14
44 lines
1705 bytes
1705 bytes
It if your "Person" class has only basic type fields you can transform them
into byte[]:
public byte[] toByteArray() throws Exception {
ByteArrayOutputStream byteArrayOut = new ByteArrayOutputStream();
DataOutputStream out = new DataOutputStream(byteArrayOut);
// Write all fields from your class into out
out.writeUTF(firstName);
out.writeInt(age);
:
out.close();
return byteArrayOut.toByteArray();
}
"Frajola" <frajola@telemar.com.br> wrote in message news:3ae7539a_1@dnews...
> Dear Mic,
>
> Thanks for your help!
>
> Please, help me more:
> Think that I have a class
> named "Person" and need
> to transforme in byte[].
>
> How can I do, perdon for
> am stupid.
>
> Tanks, Frajola.
>
> frajola@telemar.com.br
> ------------------------------------------------
>
Technical Details
Message-ID:
<3ae7bbda$1_1@dnews>Path:
arc1-ca.pugleaf.net!newsfeed.google.com!sn-xit-03!supernews.com!logbridge.uoregon.edu!news.maxwell.syr.edu!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!dnewsReferences:
<3ae5bda9_2@dnews> <3ae676ab_2@dnews> <3ae7539a_1@dnews>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 1089d0,7177f458549000a1 X-Google-Attributes: gid1089d0,public X-Google-ArrivalTime: 2001-04-25 23:16:02 PST From: "Alex Maksakov" <ksp@overta.ru> Newsgroups: borland.public.jbuilder.java.api References: <3ae5bda9_2@dnews> <3ae676ab_2@dnews> <3ae7539a_1@dnews> Subject: Re: Object to Byte[]. Date: Thu, 26 Apr 2001 10:14:07 +0400 Lines: 47 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 5.00.2919.6700 X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2919.6700 NNTP-Posting-Host: 213.167.35.2 Message-ID: <3ae7bbda$1_1@dnews> X-Trace: dnews 988265434 213.167.35.2 (25 Apr 2001 23:10:34 -0700) Path: arc1-ca.pugleaf.net!newsfeed.google.com!sn-xit-03!supernews.com!logbridge.uoregon.edu!news.maxwell.syr.edu!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!dnews