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

bilco
stranger


Reged: 10/16/06
Posts: 1
Use IO to get the Size of Serializable Objects
      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


Entire topic
Subject Posted by Posted on
* Use IO to get the Size of Serializable Objects bilco 10/16/06 07:33 AM

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

Moderator:   



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

Rating:
Thread views: 7451

Rate this thread

Jump to

Contact us JavaWorld

Powered by UBB.threads™ 6.5.5