TeeWriter extends Writer { @Override public void write(char[] cbuf, int off, int len) throws IOException { for(Writer w : writers) { w.write(cbuf, off, len); } } TeeWriter(Writer ... writers); void addWriter(Writer writer); void removeWriter(Writer writer); @Override void close(); @Override void flush(); @Override void write(char[] cbuf, int off, int len);  }
@Test public void testWrite() throws Exception { StringWriter first = new StringWriter(); StringWriter second = new StringWriter(); StringWriter third = new StringWriter(); TeeWriter tee = null; try { tee = new TeeWriter(first, second, third); final String text = "This is some text"; tee.append(text); tee.flush(); assertEquals(text, first.getBuffer().toString()); assertEquals(text, second.getBuffer().toString()); assertEquals(text, third.getBuffer().toString()); } finally { tee.close(); } }