code: public void write(HttpServletResponse response, String text, String contentType, String encoding) {
          assertArgumentNotNull("response", response);
          assertArgumentNotNull("text", text);
          assertArgumentNotNull("contentType", contentType);
          assertArgumentNotNull("encoding", encoding);
          final String contentTypeWithCharset = buildContentTypeWithCharset(contentType, encoding);
          showWritingResponse(text, contentTypeWithCharset);
          response.setContentType(contentTypeWithCharset);
          try {
              PrintWriter out = null;
              try {
                  out = createPrintWriter(response, encoding);
                  printPrintWriter(out, text);
              } finally {
                  if (out != null) {
                      closePrintWriter(out);
                  }
              }
          } catch (IOException e) {
              String msg = "Failed to write the text: contentType=" + contentType + ", encoding=" + encoding + ", text=" + text;
              throw new IllegalStateException(msg, e);
          }
      }
docs: =========