Mercurial > hg > tema
view src/kryshen/tema/io/CopyWriter.java @ 15:e9d13c7ffeb1
Update header comment.
author | Mikhail Kryshen <mikhail@kryshen.net> |
---|---|
date | Tue, 24 Mar 2009 18:51:47 +0300 |
parents | 6c41a0b43e58 |
children |
line wrap: on
line source
/* * Copyright 2006-2009 Mikhail Kryshen * * This file is part of Tema. * * Tema is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation, either version 3 of the * License, or (at your option) any later version. * * Tema is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the * GNU Lesser General Public License along with Tema. * If not, see <http://www.gnu.org/licenses/>. */ package kryshen.tema.io; import java.io.IOException; import java.io.Writer; /** * Copies it's output to several writers. * * @author Mikhail Kryshen */ public class CopyWriter extends Writer { private final Writer[] writers; public CopyWriter(Writer... writers) { this.writers = writers; } public void write(char[] cbuf, int off, int len) throws IOException { for (Writer w : writers) { w.write(cbuf, off, len); } } public void write(int c) throws IOException { for (Writer w : writers) { w.write(c); } } public void write(String str, int off, int len) throws IOException { for (Writer w : writers) { w.write(str, off, len); } } public void flush() throws IOException { for (Writer w : writers) { w.flush(); } } public void close() throws IOException { for (Writer w : writers) { w.close(); } } }