[英]Get index from bytebuffer
I have to read a byteBuffer in Java. 我必须阅读Java中的byteBuffer。 I am using byteBuffer.get()
but when I read a specific value, I have to get the offset in the byteBuffer. 我正在使用byteBuffer.get()
但是当我读取特定值时,我必须获取byteBuffer中的偏移量。 How can I do that ? 我怎样才能做到这一点 ?
For example 例如
byte name = byteBuffer.get();
byte location = byteBuffer.get();
for (int i=1; i<16; i++){
//Here I want to get the offset in the byteBuffer like bytebuffer.getOffsset() or something like that
MyObject myObject = new MyObject();
byteBuffer.get(myObject);
}
I want to get all offset for each "MyObject" Is there something to do to get these offsets ? 我想获取每个“ MyObject”的所有偏移量是否要做一些事情来获取这些偏移量?
int offset = byteBuffer.position();
这是Buffer类的方法,因此您可能忽略了它。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.