Package com.google.gwt.user.server.rpc
Class TeeWriter<W extends java.io.Writer>
- java.lang.Object
-
- java.io.Writer
-
- java.io.FilterWriter
-
- com.google.gwt.user.server.rpc.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.FilterWriterA 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 usenullas the other writer in which case thisTeeWriterbehaves like a regularFilterWriter. The other writer can be obtained by callinggetOtherWriter(). This can, e.g., be used with aStringWriterfrom which the output written to this writer can later be obtained as a singleString.
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()voidflush()WgetOtherWriter()voidsetOtherWriter(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.voidwrite(char[] cbuf, int off, int len)voidwrite(int c)voidwrite(java.lang.String str, int off, int len)
-
-
-
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 thewritemethods.
-
write
public void write(int c) throws java.io.IOException- Overrides:
writein classjava.io.FilterWriter- Throws:
java.io.IOException
-
write
public void write(char[] cbuf, int off, int len) throws java.io.IOException- Overrides:
writein classjava.io.FilterWriter- Throws:
java.io.IOException
-
write
public void write(java.lang.String str, int off, int len) throws java.io.IOException- Overrides:
writein classjava.io.FilterWriter- Throws:
java.io.IOException
-
flush
public void flush() throws java.io.IOException- Specified by:
flushin interfacejava.io.Flushable- Overrides:
flushin classjava.io.FilterWriter- Throws:
java.io.IOException
-
close
public void close() throws java.io.IOException- Specified by:
closein interfacejava.lang.AutoCloseable- Specified by:
closein interfacejava.io.Closeable- Overrides:
closein classjava.io.FilterWriter- Throws:
java.io.IOException
-
-