docs: static BitArray interleaveWithECBytes(BitArray bits,
                                          int numTotalBytes,
                                          int numDataBytes,
                                          int numRSBlocks) throws WriterException {
  
      // "bits" must have "getNumDataBytes" bytes of data.
      if (bits.getSizeInBytes() != numDataBytes) {
        throw new WriterException("Number of bits and data bytes does not match");
      }
  
      // Step 1.  Divide data bytes into blocks and generate error correction bytes for them. We'll
      // store the divided data bytes blocks and error correction bytes blocks into "blocks".
      int dataBytesOffset = 0;
      int maxNumDataBytes = 0;
      int maxNumEcBytes = 0;
  
      // Since, we know the number of reedsolmon blocks, we can initialize the vector with the number.
      Collection<BlockPair> blocks = new ArrayList<>(numRSBlocks);
  
      for (int i = 0; i < numRSBlocks; ++i) {
        int[] numDataBytesInBlock = new int[1];
        int[] numEcBytesInBlock = new int[1];
        getNumDataBytesAndNumECBytesForBlockID(
            numTotalBytes, numDataBytes, numRSBlocks, i,
            numDataBytesInBlock, numEcBytesInBlock);
  
        int size = numDataBytesInBlock[0];
        byte[] dataBytes = new byte[size];
        bits.toBytes(8 * dataBytesOffset, dataBytes, 0, size);
        byte[] ecBytes = generateECBytes(dataBytes, numEcBytesInBlock[0]);
        blocks.add(new BlockPair(dataBytes, ecBytes));
  
        maxNumDataBytes = Math.max(maxNumDataBytes, size);
        maxNumEcBytes = Math.max(maxNumEcBytes, ecBytes.length);
        dataBytesOffset += numDataBytesInBlock[0];
      }
      if (numDataBytes != dataBytesOffset) {
        throw new WriterException("Data bytes does not match offset");
      }
  
      BitArray result = new BitArray();
  
      // First, place data blocks.
      for (int i = 0; i < maxNumDataBytes; ++i) {
        for (BlockPair block : blocks) {
          byte[] dataBytes = block.getDataBytes();
          if (i < dataBytes.length) {
            result.appendBits(dataBytes[i], 8);
          }
        }
      }
      // Then, place error correction blocks.
      for (int i = 0; i < maxNumEcBytes; ++i) {
        for (BlockPair block : blocks) {
          byte[] ecBytes = block.getErrorCorrectionBytes();
          if (i < ecBytes.length) {
            result.appendBits(ecBytes[i], 8);
          }
        }
      }
      if (numTotalBytes != result.getSizeInBytes()) {  // Should be same.
        throw new WriterException("Interleaving error: " + numTotalBytes + " and " +
            result.getSizeInBytes() + " differ.");
      }
  
      return result;
    }