code: public static byte[] toByteArray(Streamable streamable) {
          try {
              final ByteArrayOutputStream baos = new ByteArrayOutputStream(streamable.size());
              final DataOutputStream dos = new DataOutputStream(baos);
              streamable.write(dos);
              dos.flush();
              baos.close();
              return baos.toByteArray();
          } catch (IOException e) {
              throw new RuntimeException(e);
          }
      }
docs: Serializes a {@link Streamable} into a byte array.
  @param streamable The object to serialize.
  @return A byte array containing the serialized object.