This content has been marked as final. Show 2 replies
Write yourself a FilterOutputStream that does monitoring in the write() methods and put it between the OOS and whatever it is presently wrapped around, e.g. FileOuputStream or Socket.getOutputStream().
However there's no useful way to know the size of an impending serialization other than to do it twice, once to a ByteArrayOutputStream to measure it, and again to the real target, which is pretty wasteful.
Are these objects so large that you really need to do this?