断点调试时查看一个对象序列化后的字节大小

仅供拷贝,无干货

java.io.ByteArrayOutputStream bos = new java.io.ByteArrayOutputStream();
java.io.ObjectOutputStream out = new java.io.ObjectOutputStream(bos);
out.writeObject(theObject);
System.out.println(bos.toByteArray().length);
out.close();

Leave a Comment

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.