Please join us at the new JavaWorld Q&A Forums. Your existing login will work there. The discussions here are now read-only.


JavaWorld Talkback >> 958763

Pages: 1
bilco
stranger


Reged: 10/16/06
Posts: 1
Use IO to get the Size of Serializable Objects
      #39158 - 10/16/06 07:33 AM

Code:

public static int getObjectSize
(
Serializable obj
)
{
byte[] ba = null;

try
{
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ObjectOutputStream oos = new ObjectOutputStream( baos );
oos.writeObject( obj );
oos.close();
ba = baos.toByteArray();
baos.close();
}
catch ( IOException ioe )
{
ioe.printStackTrace();
return 0;
}
return ba.length;
}



Post Extras: Print Post   Remind Me!   Notify Moderator  
Pages: 1



Extra information
0 registered and 1 anonymous users are browsing this forum.

Moderator:   

Print Topic

Forum Permissions
      You cannot start new topics
      You cannot reply to topics
      HTML is disabled
      UBBCode is enabled

Rating:
Topic views: 7450

Rate this topic

Jump to

Contact us JavaWorld

Powered by UBB.threads™ 6.5.5