code: protected static void writeInt(ChannelBuffer buf, int value) {
          if (value < 10) {
              buf.writeByte('0' + value);
              return;
          }
  
          StringBuilder sb = new StringBuilder(8);
          while (value > 0) {
              int digit = value % 10;
              sb.append((char) ('0' + digit));
              value /= 10;
          }
  
          for (int i = sb.length() - 1; i >= 0; i--) {
              buf.writeByte(sb.charAt(i));
          }
      }
docs: Write the textual value of a positive integer to the supplied buffer.
  
  @param buf   Buffer to write to.
  @param value Value to write.