public static byte[] bytes(Streamable streamable) {
        if (streamable == null) return null;

        ByteArrayOutputStream stream = new ByteArrayOutputStream();
        try {
            streamable.write(stream);
        } catch (IOException e) {
            throw new ApplicationException(e);
        }
        return stream.toByteArray();
    }
public static byte [ ] bytes ( Streamable streamable ) { if ( streamable == null ) return null ; ByteArrayOutputStream stream = new ByteArrayOutputStream ( ) ; try { streamable . write ( stream ) ; } catch ( IOException e ) { throw new ApplicationException ( e ) ; } return stream . toByteArray ( ) ; }
Serializes a {@link Streamable} object and returns the byte array.

@param streamable the object to be serialized
@return an array of bytes representing the given streamable object.