code: public static void quoteIfNeeded(StringBuilder buf, String str, String delim) {
          if (str == null) {
              return;
          }
          // check for delimiters in input string
          int len = str.length();
          if (len == 0) {
              return;
          }
          int ch;
          for (int i = 0; i < len; i++) {
              ch = str.codePointAt(i);
              if (delim.indexOf(ch) >= 0) {
                  // found a delimiter codepoint. we need to quote it.
                  quote(buf, str);
                  return;
              }
          }
  
          // no special delimiters used, no quote needed.
          buf.append(str);
      }
docs: Append into buf the provided string, adding quotes if needed.
  <p>
  Quoting is determined if any of the characters in the <code>delim</code> are found in the input <code>str</code>.
  
  @param buf   the buffer to append to
  @param str   the string to possibly quote
  @param delim the delimiter characters that will trigger automatic quoting