org.linkedin.util-core/src/main/java/org/linkedin/util/io/IOUtils.java
public static <T extends Serializable> byte[] serialize(T ser)
    throws IOException
  {
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    ObjectOutputStream oos = new ObjectOutputStream(baos);
    try
    {
      oos.writeObject(ser);
    }
    finally
    {
      oos.close();
    }
    return baos.toByteArray();
  }
public static <T extends Serializable> byte[] serialize(T ser)
    throws IOException
  {
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    ObjectOutputStream oos = new ObjectOutputStream(baos);
    try
    {
      oos.writeObject(ser);
    }
    finally
    {
      oos.close();
    }
    return baos.toByteArray();
  }
Turns the object into a <code>byte[]</code> by serializing it in memory.

@param ser the serializable object
@exception IOException if there is a problem in the serialization step