Concat two ByteBuffers in Java -


how can concat 2 bytebuffers 1 bytebuffer?

the following doesn't work:

    bytebuffer bb = bytebuffer.allocate(100);     bytebuffer bb2 = bytebuffer.allocate(200);     bb.allocate(200).put(bb2);     system.out.println(bb.array().length); 

the length of bb still 100.

something

bb = bytebuffer.allocate(300).put(bb).put(bb2); 

should job: create buffer large enough hold contents of both buffers, , use relative put-methods fill first , second buffer. (the put method returns instance method called on, way)


Comments

Popular posts from this blog

My HTML document is not linking to my CSS stylesheet properly -

php array slice every 2th rule -

node.js - Sending sockets to client side, Error: Converting circular structure to JSON -