星期三, 二月 02, 2005

如何得到Java 对象的大小Size.

Object ob = new Object();

ByteArrayOutputStream out = new ByteArrayOutputStream();
ObjectOutputStream objOut = new ObjectOutputStream(out);
objOut.writeObject(ob);

System.out.println("Size = " + out.toByteArray().length);