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

How to access named pipes using JavaScript in Firefox add-on? -

multithreading - OPAL (Open Phone Abstraction Library) Transport not terminated when reattaching thread? -

node.js - req param returns an empty array -