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. import java.io.IOException;
  18. import java.io.FilterOutputStream;
  19. import java.io.OutputStream;
  20. /**
  21. *
  22. * A Proxy stream which acts as expected, that is it passes the method
  23. * calls on to the proxied stream and doesn't change which methods are
  24. * being called. It is an alternative base class to FilterOutputStream
  25. * to increase reusability.
  26. */
  27. public class ProxyOutputStream extends FilterOutputStream {
  28. private OutputStream proxy;
  29. /**
  30. * Constructs a new ProxyOutputStream.
  31. * @param proxy OutputStream to delegate to
  32. */
  33. public ProxyOutputStream(OutputStream proxy) {
  34. super(proxy);
  35. this.proxy = proxy;
  36. }
  37. /** @see java.io.OutputStream#write(int) */
  38. public void write(int idx) throws IOException {
  39. this.proxy.write(idx);
  40. }
  41. /** @see java.io.OutputStream#write(byte[]) */
  42. public void write(byte[] bts) throws IOException {
  43. this.proxy.write(bts);
  44. }
  45. /** @see java.io.OutputStream#write(byte[], int, int) */
  46. public void write(byte[] bts, int st, int end) throws IOException {
  47. this.proxy.write(bts, st, end);
  48. }
  49. /** @see java.io.OutputStream#flush() */
  50. public void flush() throws IOException {
  51. this.proxy.flush();
  52. }
  53. /** @see java.io.OutputStream#close() */
  54. public void close() throws IOException {
  55. this.proxy.close();
  56. }
  57. }