code: public StringBuilder contentsAsStringBuilder(int extraSpace)
      {
          if (mResultString != null) {
              return new StringBuilder(mResultString);
          }
          if (mResultArray != null) {
              StringBuilder sb = new StringBuilder(mResultArray.length + extraSpace);
              sb.append(mResultArray, 0, mResultArray.length);
              return sb;
          }
          if (mInputStart >= 0) { // shared array
              if (mInputLen < 1) {
                  return new StringBuilder();
              }
              StringBuilder sb = new StringBuilder(mInputLen + extraSpace);
              sb.append(mInputBuffer, mInputStart, mInputLen);
              return sb;
          }
          int segLen = mSegmentSize;
          int currLen = mCurrentSize;
  
          StringBuilder sb = new StringBuilder(segLen + currLen + extraSpace);
          // First stored segments
          if (mSegments != null) {
              for (int i = 0, len = mSegments.size(); i < len; ++i) {
                  char[] curr = mSegments.get(i);
                  sb.append(curr, 0, curr.length);
              }
          }
          // And finally, current segment:
          sb.append(mCurrentSegment, 0, currLen);
          return sb;
      }
docs: Similar to {@link #contentsAsString}, but constructs a StringBuilder
  for further appends.
  
  @param extraSpace Number of extra characters to preserve in StringBuilder
  beyond space immediately needed to hold the contents