code: private static ByteBuffer copyAll(List<ByteBuffer> buffers) {
      int size = 0;
      for (ByteBuffer b : buffers) {
        size += b.remaining();
      }
      ByteBuffer result = allocate(size);
      for (ByteBuffer b : buffers) {
        result.put(b);
      }
      result.flip();
      return result;
    }
docs: Copies a list of byteBuffers into a single new byteBuffer.