我必须阅读Java中的byteBuffer。我正在使用,byteBuffer.get()
但是当我读取特定值时,必须在byteBuffer中获取偏移量。我怎样才能做到这一点 ?
例如
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);
}
我想获取每个“ MyObject”的所有偏移量是否要做一些事情来获取这些偏移量?
int offset = byteBuffer.position();
这是Buffer类的方法,因此您可能忽略了它。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句