• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /**
2  * ****************************************************************************** Copyright (C)
3  * 1996-2001, International Business Machines Corporation and * others. All Rights Reserved. *
4  * ******************************************************************************
5  *
6  * <p>$Source$ $Revision$
7  *
8  * <p>******************************************************************************
9  */
10 package org.unicode.cldr.util;
11 
12 import java.io.IOException;
13 import java.io.Writer;
14 
15 public final class DualWriter extends Writer {
16 
17     private boolean autoflush;
18     private Writer a;
19     private Writer b;
20 
DualWriter(Writer a, Writer b)21     public DualWriter(Writer a, Writer b) {
22         this.a = a;
23         this.b = b;
24     }
25 
DualWriter(Writer a, Writer b, boolean autoFlush)26     public DualWriter(Writer a, Writer b, boolean autoFlush) {
27         this.a = a;
28         this.b = b;
29         autoflush = autoFlush;
30     }
31 
setAutoFlush(boolean value)32     public void setAutoFlush(boolean value) {
33         autoflush = value;
34     }
35 
getAutoFlush()36     public boolean getAutoFlush() {
37         return autoflush;
38     }
39 
40     @Override
write(char cbuf[], int off, int len)41     public void write(char cbuf[], int off, int len) throws IOException {
42         a.write(cbuf, off, len);
43         b.write(cbuf, off, len);
44         if (autoflush) flush();
45     }
46 
47     @Override
close()48     public void close() throws IOException {
49         a.close();
50         b.close();
51     }
52 
53     @Override
flush()54     public void flush() throws IOException {
55         a.flush();
56         b.flush();
57     }
58 }
59