code: static byte[] pollAndConvertToByteArray(final int totalCapacity,
              final Queue<ByteBuffer> dataArray) {
  
          final byte[] wholeData = new byte[totalCapacity];
  
          int destStartIndex = 0;
  
          ByteBuffer data;
          while ((data = dataArray.poll()) != null) {
              final byte[] array = data.array();
              System.arraycopy(array, 0, wholeData, destStartIndex, array.length);
              destStartIndex += array.length;
              if (destStartIndex == totalCapacity) {
                  break;
              }
          }
  
          return wholeData;
      }
docs: (default)