code: private void writeSelectorsAndHuffmanTables(ByteBuf out) {
          final Bzip2BitWriter writer = this.writer;
          final byte[] selectors = this.selectors;
          final int totalSelectors = selectors.length;
          final int[][] huffmanCodeLengths = this.huffmanCodeLengths;
          final int totalTables = huffmanCodeLengths.length;
          final int mtfAlphabetSize = this.mtfAlphabetSize;
  
          writer.writeBits(out, 3, totalTables);
          writer.writeBits(out, 15, totalSelectors);
  
          // Write the selectors
          Bzip2MoveToFrontTable selectorMTF = new Bzip2MoveToFrontTable();
          for (byte selector : selectors) {
              writer.writeUnary(out, selectorMTF.valueToFront(selector));
          }
  
          // Write the Huffman tables
          for (final int[] tableLengths : huffmanCodeLengths) {
              int currentLength = tableLengths[0];
  
              writer.writeBits(out, 5, currentLength);
  
              for (int j = 0; j < mtfAlphabetSize; j++) {
                  final int codeLength = tableLengths[j];
                  final int value = currentLength < codeLength ? 2 : 3;
                  int delta = Math.abs(codeLength - currentLength);
                  while (delta-- > 0) {
                      writer.writeBits(out, 2, value);
                  }
                  writer.writeBoolean(out, false);
                  currentLength = codeLength;
              }
          }
      }
docs: Write out the selector list and Huffman tables.