code: public void writeTo(Writer target, boolean flushTarget, boolean emptyAfter)
              throws IOException
      {
          //if (target instanceof GrailsWrappedWriter) {
          //    target = ((GrailsWrappedWriter)target).unwrap();
          //}
          if (target instanceof StreamCharBufferWriter)
          {
              if (target == writer)
              {
                  throw new IllegalArgumentException(
                          "Cannot write buffer to itself.");
              }
              ((StreamCharBufferWriter) target).write(this);
              return;
          }
          writeToImpl(target, flushTarget, emptyAfter);
      }
docs: Writes the buffer content to a target java.io.Writer
  
  @param target Writer
  @param flushTarget calls target.flush() before finishing
  @param emptyAfter empties the buffer if true
  @throws IOException