KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > commons > io > output > ProxyOutputStream


1 /*
2  * Copyright 2002-2004 The Apache Software Foundation.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16 package org.apache.commons.io.output;
17
18 import java.io.IOException JavaDoc;
19 import java.io.FilterOutputStream JavaDoc;
20 import java.io.OutputStream JavaDoc;
21
22 /**
23  *
24  * A Proxy stream which acts as expected, that is it passes the method
25  * calls on to the proxied stream and doesn't change which methods are
26  * being called. It is an alternative base class to FilterOutputStream
27  * to increase reusability.
28  */

29 public class ProxyOutputStream extends FilterOutputStream JavaDoc {
30
31     private OutputStream JavaDoc proxy;
32
33     /**
34      * Constructs a new ProxyOutputStream.
35      * @param proxy OutputStream to delegate to
36      */

37     public ProxyOutputStream(OutputStream JavaDoc proxy) {
38         super(proxy);
39         this.proxy = proxy;
40     }
41
42     /** @see java.io.OutputStream#write(int) */
43     public void write(int idx) throws IOException JavaDoc {
44         this.proxy.write(idx);
45     }
46
47     /** @see java.io.OutputStream#write(byte[]) */
48     public void write(byte[] bts) throws IOException JavaDoc {
49         this.proxy.write(bts);
50     }
51
52     /** @see java.io.OutputStream#write(byte[], int, int) */
53     public void write(byte[] bts, int st, int end) throws IOException JavaDoc {
54         this.proxy.write(bts, st, end);
55     }
56
57     /** @see java.io.OutputStream#flush() */
58     public void flush() throws IOException JavaDoc {
59         this.proxy.flush();
60     }
61
62     /** @see java.io.OutputStream#close() */
63     public void close() throws IOException JavaDoc {
64         this.proxy.close();
65     }
66
67 }
68
Popular Tags