public static <T>byte[] toByteArray(T value,Coder<T> coder){
  ByteArrayOutputStream baos=new ByteArrayOutputStream();
  try {
    coder.encode(value,baos,new Coder.Context(true));
  }
 catch (  IOException e) {
    throw new IllegalStateException("Error encoding value: " + value,e);
  }
  return baos.toByteArray();
}

public static < T > byte [ ] toByteArray ( T value , Coder < T > coder ) { ByteArrayOutputStream baos = new ByteArrayOutputStream ( ) ; try { coder . encode ( value , baos , new Coder . Context ( true ) ) ; } catch ( IOException e ) { throw new IllegalStateException ( "Error encoding value: " + value , e ) ; } return baos . toByteArray ( ) ; }
utility method for serializing an object using the specified coder .
