Scala:如何将protobuf ByteString对象转换为字节?

时间:2017-06-14 17:24:53

标签: scala protocol-buffers scala-java-interop

我有一个返回ByteString对象的函数:

private def getEvent(value: DataOutputValue): com.google.protobuf.ByteString = {
  value.getRecordedEvent.getEvent.getEvent
}

如何从Scala中获取这些字节?

1 个答案:

答案 0 :(得分:3)

致电toByteArray

val bytes = getEvent(someDateOutput).toByteArray