我想将 ByteArray 转换为字符串,然后将字符串转换为 ByteArray,但是在转换值时发生了变化。有人帮助解决这个问题。
人.proto:
syntax = "proto3";
message Person{
string name = 1;
int32 age = 2;
}
在 sbt compile 之后,它给出了案例类 Person(由 google protobuf 在编译时创建)
我的主课:
val newPerson = Person(
name = "John Cena",
age = 44 //output
)
println(newPerson.toByteArray) //[B@50da041d
val l = newPerson.toByteArray.toString
println(l) //[B@7709e969
val l1 = l.getBytes
println(l1) //[B@f44b405
为什么价值观改变了?如何正确转换??