code: public static String stringLiteral(String data) {
      StringBuilder result = new StringBuilder();
      result.append('"');
      for (int i = 0; i < data.length(); i++) {
        char c = data.charAt(i);
        switch (c) {
          case '"':
            result.append("\\\"");
            break;
          case '\\':
            result.append("\\\\");
            break;
          case '\t':
            result.append("\\\t");
            break;
          case '\b':
            result.append("\\\b");
            break;
          case '\n':
            result.append("\\\n");
            break;
          case '\r':
            result.append("\\\r");
            break;
          case '\f':
            result.append("\\\f");
            break;
          default:
            result.append(c);
        }
      }
      result.append('"');
      return result.toString();
    }
docs: Returns the string literal representing {@code data}, including wrapping
  quotes.