code: public static void quoteOnly(Appendable buffer, String input) {
          if (input == null)
              return;
  
          try {
              buffer.append('"');
              for (int i = 0; i < input.length(); ++i) {
                  char c = input.charAt(i);
                  if (c == '"' || c == '\\')
                      buffer.append('\\');
                  buffer.append(c);
              }
              buffer.append('"');
          } catch (IOException x) {
              throw new RuntimeException(x);
          }
      }
docs: Quote a string into an Appendable. Only quotes and backslash are escaped.
  
  @param buffer The Appendable
  @param input  The String to quote.