I think this should be after `oos.writeObject(o);`, in case there is buffered data. In any case, before obtaining the `byte[]` result.