Code example for ByteArrayDataOutput

Methods: toByteArray

  private void verifyDecodingSupportsV1(TransactionEdit edit) throws IOException {
    TransactionEdit.TransactionEditCodecV1 v1Codec = new TransactionEdit.TransactionEditCodecV1();
    // encoding with codec of v1 
    ByteArrayDataOutput out = ByteStreams.newDataOutput();
    v1Codec.encode(edit, out);
    // decoding 
    TransactionEdit decodedEdit = new TransactionEdit();
    DataInput in = ByteStreams.newDataInput(out.toByteArray());
    Assert.assertEquals(edit, decodedEdit);
Stop searching for code, let great code find you!  Add Codota to your java IDE