【发布时间】:2021-08-09 04:54:18
【问题描述】:
背景
构建跟随类
public class DerivedClass<T> extends BaseClass<T> {
@Override
public void invoke(T value, Context context) throws Exception {
//Send data to Kafka
// Need to covert to byte[]
}
}
问题
不确定这是否有意义,但需要将此值转换为字节数组
例如对于字符串,可以使用getBytes() 方法。如何做到这一点?
【问题讨论】:
-
这能回答你的问题吗? Java Serializable Object to Byte Array
-
另外,a basic tutorial 也是同样的事情。