Package com.google.gwt.user.server.rpc.jakarta

## Class TeeWriter<W extends java.io.Writer>

- java.lang.Object
- - java.io.Writer
  - - java.io.FilterWriter
    - - com.google.gwt.user.server.rpc.jakarta.TeeWriter<W>

- Type Parameters:
    `W` - the type of the other writer to which output is sent in parallel
  All Implemented Interfaces:
    `java.io.Closeable`, `java.io.Flushable`, `java.lang.Appendable`, `java.lang.AutoCloseable`

      public class TeeWriter<W extends java.io.Writer>
      extends java.io.FilterWriter

  A writer that wraps one writer and copies all output written to it not only to that one writer but also to another writer ("tee"). It is permissible to use `null` as the other writer in which case this `TeeWriter` behaves like a regular `FilterWriter`. The other writer can be obtained by calling `getOtherWriter()`. This can, e.g., be used with a `StringWriter` from which the output written to this writer can later be obtained as a single `String`.

- - ### Field Summary

    - ### Fields inherited from class java.io.FilterWriter

      `out`

    - ### Fields inherited from class java.io.Writer

      `lock`

  - ### Constructor Summary

    Constructors
    Constructor | Description
    --- | ---
    `TeeWriter​(java.io.Writer out, W tee)` |

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `void` | `close()` |
    `void` | `flush()` |
    `W` | `getOtherWriter()` |
    `void` | `setOtherWriter​(W tee)` | If a "tee" writer hasn't been set at construction time and as long as nothing has been written to this writer, a caller may use this method to set a "tee" writer once.
    `void` | `write​(char[] cbuf, int off, int len)` |
    `void` | `write​(int c)` |
    `void` | `write​(java.lang.String str, int off, int len)` |

    - ### Methods inherited from class java.io.Writer

      `append, append, append, nullWriter, write, write`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### TeeWriter

          public TeeWriter​(java.io.Writer out,
                           W tee)

  - ### Method Detail

    - #### getOtherWriter

          public W getOtherWriter()

    - #### setOtherWriter

          public void setOtherWriter​(W tee)

      If a "tee" writer hasn't been set at construction time and as long as nothing has been written to this writer, a caller may use this method to set a "tee" writer once.
      Throws:
        `java.lang.IllegalStateException` - in case a "tee" has already been set (or formally, `getOtherWriter()``!= null`) or data has already been written to this writer using any of the `write` methods.

    - #### write

          public void write​(int c)
                     throws java.io.IOException

      Overrides:
        `write` in class `java.io.FilterWriter`
      Throws:
        `java.io.IOException`

    - #### write

          public void write​(char[] cbuf,
                            int off,
                            int len)
                     throws java.io.IOException

      Overrides:
        `write` in class `java.io.FilterWriter`
      Throws:
        `java.io.IOException`

    - #### write

          public void write​(java.lang.String str,
                            int off,
                            int len)
                     throws java.io.IOException

      Overrides:
        `write` in class `java.io.FilterWriter`
      Throws:
        `java.io.IOException`

    - #### flush

          public void flush()
                     throws java.io.IOException

      Specified by:
        `flush` in interface `java.io.Flushable`
      Overrides:
        `flush` in class `java.io.FilterWriter`
      Throws:
        `java.io.IOException`

    - #### close

          public void close()
                     throws java.io.IOException

      Specified by:
        `close` in interface `java.lang.AutoCloseable`
      Specified by:
        `close` in interface `java.io.Closeable`
      Overrides:
        `close` in class `java.io.FilterWriter`
      Throws:
        `java.io.IOException`