方法1:
Byte[] longBytes=ByteBuffer.allocate(8).putLong(longValue).array();
方法2:
ByteArrayOutputStream bos=new ByteArrayOutputStream(8);
DataOutputStream dos=new DataOutputStream(bos);
dos.writeLong(longValue);
dos.flush();
Byte[] longBytes=bos.toByteArray();
dos.close();
bos.close();
本文深入探讨了Java中使用ByteBuffer和ByteArrayOutputStream结合DataOutputStream进行长整型数据序列化的两种方法,提供了序列化与反序列化过程的详细步骤与实例代码。
4189

被折叠的 条评论
为什么被折叠?



