1 /* 2 * Licensed to the Apache Software Foundation (ASF) under one or more 3 * contributor license agreements. See the NOTICE file distributed with 4 * this work for additional information regarding copyright ownership. 5 * The ASF licenses this file to You under the Apache License, Version 2.0 6 * (the "License"); you may not use this file except in compliance with 7 * the License. You may obtain a copy of the License at 8 * 9 * http://www.apache.org/licenses/LICENSE-2.0 10 * 11 * Unless required by applicable law or agreed to in writing, software 12 * distributed under the License is distributed on an "AS IS" BASIS, 13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 * See the License for the specific language governing permissions and 15 * limitations under the License. 16 */ 17 package org.apache.commons.io.output; 18 19 import java.io.IOException; 20 import java.io.FilterOutputStream; 21 import java.io.OutputStream; 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 * @author Stephen Colebourne 30 * @version $Id: ProxyOutputStream.java 471628 2006-11-06 04:06:45Z bayard $ 31 */ 32 public class ProxyOutputStream extends FilterOutputStream { 33 34 /** 35 * Constructs a new ProxyOutputStream. 36 * 37 * @param proxy the OutputStream to delegate to 38 */ 39 public ProxyOutputStream(OutputStream proxy) { 40 super(proxy); 41 // the proxy is stored in a protected superclass variable named 'out' 42 } 43 44 /** @see java.io.OutputStream#write(int) */ 45 public void write(int idx) throws IOException { 46 out.write(idx); 47 } 48 49 /** @see java.io.OutputStream#write(byte[]) */ 50 public void write(byte[] bts) throws IOException { 51 out.write(bts); 52 } 53 54 /** @see java.io.OutputStream#write(byte[], int, int) */ 55 public void write(byte[] bts, int st, int end) throws IOException { 56 out.write(bts, st, end); 57 } 58 59 /** @see java.io.OutputStream#flush() */ 60 public void flush() throws IOException { 61 out.flush(); 62 } 63 64 /** @see java.io.OutputStream#close() */ 65 public void close() throws IOException { 66 out.close(); 67 } 68 69 }