创建原始数据或二进制读写的框架
我正在开发一个项目,其中数据必须以二进制格式读取,但可以放入结构格式。在java中结构不可用。我已以字节数组形式发送数据。它也有一定的结构。
例如
数据包
int length
int sequence no
MessageData
消息数据 消息头 消息体
消息头 整数数据1 长数据2 char[] data3//2字节 char[] data4//3 bytes
与 MessageBody 相同
,但数据应打包在字节数组中。
可以在CPP中实现,就像
#pragma(2) //for word alignment
struct Packet{
int length
int sequence no
MessageData msgdata
}
我必须在java中实现一样。
为了读取数据,我使用 Preon 库
但是为了写入数据,我仍然使用正常方法将数据打包在字节数组中在某些功能的帮助下 任何人都在从事同类项目或有更好的想法
I am working on one project in which data has to read in binary format but one can put into a structure format. In java Structure is not available. I have send the data in byte array. It also has some structure.
For Example
Packet
int length
int sequence no
MessageData
MessageData
MessageHeader
MessageBody
MessageHeader
int data1
long data2
char[] data3//2bytes
char[] data4//3 bytes
Same for MessageBody
But data should be packed in byte array.
One can do in CPP as
#pragma(2) //for word alignment
struct Packet{
int length
int sequence no
MessageData msgdata
}
I have to implement in java.
for reading data I am using Preon library
But for writing data I am still using normal method for packaging data in byte array with help of some function
Anybody have work on same kind project or have better idea
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
当前的代码库确实包含一些用于写入数据的字节,但是尚未完成。话虽如此,它可能适用于您当前的情况:
The current codebase does contain some bytes for writing data, however, it's not completed yet. Having said that, it might work for your current case: