title: CharResponseWrapper captured content is empty
body: <p>I have tried the following example to replace some content in my servlet response.</p>
  
  <p><a href="https://docs.oracle.com/cd/E19575-01/819-3669/bnagd/index.html" rel="nofollow">Programming Customized Requests and Responses</a></p>
  
  <p><strong>test.html</strong></p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html lang="en" xmlns:th="http://www.thymeleaf.org"&gt;
  &lt;head&gt;
      &lt;meta charset="UTF-8"&gt;&lt;/meta&gt;
      &lt;link th:href="@{/css/test.css}" rel="stylesheet"&gt;&lt;/link&gt;
      &lt;title&gt;Test&lt;/title&gt;
  &lt;/head&gt;
  &lt;body&gt;
      &lt;p class="forbiddenClass"&gt;Test!&lt;/p&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p><strong>test.css:</strong></p>
  
  <pre><code>.forbiddenClass {
      color: red;
  }
  </code></pre>
  
  <p><strong>CharResponseWrapper.java</strong></p>
  
  <pre><code>public class CharResponseWrapper extends HttpServletResponseWrapper {
  
      private final CharArrayWriter output;
  
      public CharResponseWrapper(final HttpServletResponse response) {
          super(response);
          output = new CharArrayWriter();
      }
  
      public String toString() {
          return output.toString();
      }
  
      public PrintWriter getWriter() {
          return new PrintWriter(output);
      }
  }
  </code></pre>
  
  <p><strong>ClassReplacementFilter.java</strong></p>
  
  <pre><code>@Component
  public class ClassReplacementFilter extends GenericFilterBean {
  
      @Override
      public void doFilter(final ServletRequest request, final ServletResponse response, final FilterChain chain)
              throws IOException, ServletException {
  
          final CharResponseWrapper wrapper = new CharResponseWrapper((HttpServletResponse) response);
          chain.doFilter(request, wrapper);
  
          String content = wrapper.toString();
          if (StringUtils.isEmpty(content)) {
              System.out.println("content is empty for content type: " + response.getContentType());
          } else {
              content = content.replaceAll("forbiddenClass", "correctClass");
              response.setContentLength(content.getBytes().length);
              response.getOutputStream().write(content.getBytes());
          }
      }
  }
  </code></pre>
  
  <p>As you might see, I want to replace the string <code>forbiddenClass</code> with <code>correctClass</code>, but it only works for the html file. The content of test.css does not change and the following message of the filter is printed to output.</p>
  
  <pre><code>content is empty for content type: text/css;charset=UTF-8
  </code></pre>
  
  <p><strong>Why is the content empty for test.css?</strong></p>