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 source
1 /*
2 * Copyright 2006-2009 Mikhail Kryshen
3 *
4 * This file is part of Tema.
5 *
6 * Tema is free software: you can redistribute it and/or modify it
7 * under the terms of the GNU Lesser General Public License as
8 * published by the Free Software Foundation, either version 3 of the
9 * License, or (at your option) any later version.
10 *
11 * Tema is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU Lesser General Public License for more details.
15 *
16 * You should have received a copy of the
17 * GNU Lesser General Public License along with Tema.
18 * If not, see <http://www.gnu.org/licenses/>.
19 */
21 package kryshen.tema.io;
23 import java.io.IOException;
24 import java.io.Writer;
26 /**
27 * Copies it's output to several writers.
28 *
29 * @author Mikhail Kryshen
30 */
31 public class CopyWriter extends Writer {
32 private final Writer[] writers;
34 public CopyWriter(Writer... writers) {
35 this.writers = writers;
36 }
38 public void write(char[] cbuf, int off, int len) throws IOException {
39 for (Writer w : writers) {
40 w.write(cbuf, off, len);
41 }
42 }
44 public void write(int c) throws IOException {
45 for (Writer w : writers) {
46 w.write(c);
47 }
48 }
50 public void write(String str, int off, int len) throws IOException {
51 for (Writer w : writers) {
52 w.write(str, off, len);
53 }
54 }
56 public void flush() throws IOException {
57 for (Writer w : writers) {
58 w.flush();
59 }
60 }
62 public void close() throws IOException {
63 for (Writer w : writers) {
64 w.close();
65 }
66 }
67 }