concatenate two byteBuffers to a single

我的梦境 提交于 2019-12-10 06:31:20

问题


Hi I've 2 byteBuffers and I want to concatenate them together to a single byteBuffer. I found a similar question here but none of the suggestions there worked for me.


回答1:


You can do it like this

    ByteBuffer b3 = ByteBuffer.allocate(b1.limit() + b2.limit());
    b3.put(b1);
    b3.put(b2);


来源:https://stackoverflow.com/questions/30734268/concatenate-two-bytebuffers-to-a-single

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!