Пример #1
0
 /** Serializes the {@code message} into a byte array using the given {@code schema}. */
 public static <T> byte[] toByteArray(T message, Schema<T> schema, boolean numeric) {
   final ByteArrayOutputStream baos = new ByteArrayOutputStream();
   try {
     writeTo(baos, message, schema, numeric);
   } catch (IOException e) {
     throw new RuntimeException(
         "Serializing to a byte array threw an IOException " + "(should never happen).", e);
   }
   return baos.toByteArray();
 }
Пример #2
0
 @Override
 protected <T> void writeTo(OutputStream out, T message, Schema<T> schema) throws IOException {
   SmileIOUtil.writeTo(out, message, schema, false);
 }