Class ProxyWriter

java.lang.Object
java.io.Writer
java.io.FilterWriter
org.apache.commons.io.output.ProxyWriter
All Implemented Interfaces:
Closeable, Flushable, Appendable, AutoCloseable
Direct Known Subclasses:
CloseShieldWriter, FileWriterWithEncoding, TaggedWriter

public class ProxyWriter extends FilterWriter
A Proxy stream which acts as expected, that is it passes the method calls on to the proxied stream and doesn't change which methods are being called. It is an alternative base class to FilterWriter to increase reusability, because FilterWriter changes the methods being called, such as write(char[]) to write(char[], int, int) and write(String) to write(String, int, int).
  • Constructor Summary

    Constructors
    Constructor
    Description
    Constructs a new ProxyWriter.
  • Method Summary

    Modifier and Type
    Method
    Description
    append(char c)
    Invokes the delegate's append(char) method.
    Invokes the delegate's append(CharSequence) method.
    append(CharSequence csq, int start, int end)
    Invokes the delegate's append(CharSequence, int, int) method.
    void
    Invokes the delegate's close() method.
    void
    Invokes the delegate's flush() method.
    void
    write(char[] cbuf)
    Invokes the delegate's write(char[]) method.
    void
    write(char[] cbuf, int off, int len)
    Invokes the delegate's write(char[], int, int) method.
    void
    write(int c)
    Invokes the delegate's write(int) method.
    void
    Invokes the delegate's write(String) method.
    void
    write(String str, int off, int len)
    Invokes the delegate's write(String) method.

    Methods inherited from class java.io.Writer

    nullWriter

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • ProxyWriter

      public ProxyWriter(Writer proxy)
      Constructs a new ProxyWriter.
      Parameters:
      proxy - the Writer to delegate to
  • Method Details

    • append

      public Writer append(char c) throws IOException
      Invokes the delegate's append(char) method.
      Specified by:
      append in interface Appendable
      Overrides:
      append in class Writer
      Parameters:
      c - The character to write
      Returns:
      this writer
      Throws:
      IOException - if an I/O error occurs.
      Since:
      2.0
    • append

      public Writer append(CharSequence csq) throws IOException
      Invokes the delegate's append(CharSequence) method.
      Specified by:
      append in interface Appendable
      Overrides:
      append in class Writer
      Parameters:
      csq - The character sequence to write
      Returns:
      this writer
      Throws:
      IOException - if an I/O error occurs.
      Since:
      2.0
    • append

      public Writer append(CharSequence csq, int start, int end) throws IOException
      Invokes the delegate's append(CharSequence, int, int) method.
      Specified by:
      append in interface Appendable
      Overrides:
      append in class Writer
      Parameters:
      csq - The character sequence to write
      start - The index of the first character to write
      end - The index of the first character to write (exclusive)
      Returns:
      this writer
      Throws:
      IOException - if an I/O error occurs.
      Since:
      2.0
    • close

      public void close() throws IOException
      Invokes the delegate's close() method.
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
      Overrides:
      close in class FilterWriter
      Throws:
      IOException - if an I/O error occurs.
    • flush

      public void flush() throws IOException
      Invokes the delegate's flush() method.
      Specified by:
      flush in interface Flushable
      Overrides:
      flush in class FilterWriter
      Throws:
      IOException - if an I/O error occurs.
    • write

      public void write(char[] cbuf) throws IOException
      Invokes the delegate's write(char[]) method.
      Overrides:
      write in class Writer
      Parameters:
      cbuf - the characters to write
      Throws:
      IOException - if an I/O error occurs.
    • write

      public void write(char[] cbuf, int off, int len) throws IOException
      Invokes the delegate's write(char[], int, int) method.
      Overrides:
      write in class FilterWriter
      Parameters:
      cbuf - the characters to write
      off - The start offset
      len - The number of characters to write
      Throws:
      IOException - if an I/O error occurs.
    • write

      public void write(int c) throws IOException
      Invokes the delegate's write(int) method.
      Overrides:
      write in class FilterWriter
      Parameters:
      c - the character to write
      Throws:
      IOException - if an I/O error occurs.
    • write

      public void write(String str) throws IOException
      Invokes the delegate's write(String) method.
      Overrides:
      write in class Writer
      Parameters:
      str - the string to write
      Throws:
      IOException - if an I/O error occurs.
    • write

      public void write(String str, int off, int len) throws IOException
      Invokes the delegate's write(String) method.
      Overrides:
      write in class FilterWriter
      Parameters:
      str - the string to write
      off - The start offset
      len - The number of characters to write
      Throws:
      IOException - if an I/O error occurs.