public byte[] serializeToBuffer(Object o) throws IOException {
  ByteArrayOutputStream bufOut=new ByteArrayOutputStream();
  try {
    serialize(bufOut,o);
    bufOut.flush();
    return bufOut.toByteArray();
  }
  finally {
    bufOut.close();
  }
}

public byte [ ] serializeToBuffer ( Object o ) throws IOException { ByteArrayOutputStream bufOut = new ByteArrayOutputStream ( ) ; try { serialize ( bufOut , o ) ; bufOut . flush ( ) ; return bufOut . toByteArray ( ) ; } finally { bufOut . close ( ) ; } }
serializes the object into a byte buffer .
