[英]Get index from bytebuffer
我必須閱讀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類的方法,因此您可能忽略了它。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.