public static ByteBuffer merge ( final ByteBuffer ... dataArray ) { int totalCapacity = 0 ; for ( final ByteBuffer data : dataArray ) { totalCapacity += data . capacity ( ) ; } final ByteBuffer wholeData = ByteBuffer . allocate ( totalCapacity ) ; for ( final ByteBuffer data : dataArray ) { wholeData . put ( data ) ; } wholeData . flip ( ) ; return wholeData ; }
Merges and returns ByteBuffer from the given dataArray . The ByteBuffer will be returned after flip .