public static byte[] serializeObject(final Object object) throws IOException {
        final ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
        final ObjectOutputStream out = new ObjectOutputStream(outputStream);
        out.writeObject(object);
        out.close();
        return outputStream.toByteArray();
    }
@author Marko A. Rodriguez (http://markorodriguez.com)
gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/util/Serializer.java