code: public String substring(final int startIndex, int endIndex) {
          endIndex = validateRange(startIndex, endIndex);
          return new String(buffer, startIndex, endIndex - startIndex);
      }
docs: Extracts a portion of this string builder as a string.
  <p>
  Note: This method treats an endIndex greater than the length of the
  builder as equal to the length of the builder, and continues
  without error, unlike StringBuffer or String.
  
  @param startIndex  the start index, inclusive, must be valid
  @param endIndex  the end index, exclusive, must be valid except
  that if too large it is treated as end of string
  @return the new string
  @throws IndexOutOfBoundsException if the index is invalid