public void writeBinary(final PacketOutputStream os) throws IOException {
  ByteArrayOutputStream baos=new ByteArrayOutputStream();
  ObjectOutputStream oos=new ObjectOutputStream(baos);
  oos.writeObject(object);
  os.write(baos.toByteArray());
}

public void writeBinary ( final PacketOutputStream os ) throws IOException { ByteArrayOutputStream baos = new ByteArrayOutputStream ( ) ; ObjectOutputStream oos = new ObjectOutputStream ( baos ) ; oos . writeObject ( object ) ; os . write ( baos . toByteArray ( ) ) ; }
write data in binary format to buffer .
