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