code: public static void append(StringBuilder buf, String s, int offset, int length) {
          synchronized (buf) {
              int end = offset + length;
              for (int i = offset; i < end; i++) {
                  if (i >= s.length())
                      break;
                  buf.append(s.charAt(i));
              }
          }
      }
docs: Append substring to StringBuilder
  
  @param buf    StringBuilder to append to
  @param s      String to append from
  @param offset The offset of the substring
  @param length The length of the substring