Fetch the repository succeeded.
有点没看懂哎
@Override
public ByteBuffer getBuffer() {
if (position == 0) {
return bufferList.get(position);
}
byte[] data = new byte[(position) * bufferList.get(0).capacity() + bufferList.get(position).limit()];
int index = 0;
for (int i = 0; i < position; i++) {
ByteBuffer b = bufferList.get(i);
System.arraycopy(b.array(), b.position(), data, index, b.remaining());
index += b.remaining();
}
ByteBuffer lastBuffer = bufferList.get(position);
System.arraycopy(lastBuffer.array(), lastBuffer.position(), data, index, lastBuffer.remaining());
return ByteBuffer.wrap(data);
}
好像确实不需要放到外面,应该是当初写代码的时候疏忽了。
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。
Sign in to comment