Package org.apache.commons.io.output
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,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 aswrite(char[]) to write(char[], int, int)andwrite(String) to write(String, int, int).
-
-
Constructor Summary
Constructors Constructor Description ProxyWriter(Writer proxy)Constructs a new ProxyWriter.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Writerappend(char c)Invokes the delegate'sappend(char)method.Writerappend(CharSequence csq)Invokes the delegate'sappend(CharSequence)method.Writerappend(CharSequence csq, int start, int end)Invokes the delegate'sappend(CharSequence, int, int)method.voidclose()Invokes the delegate'sclose()method.voidflush()Invokes the delegate'sflush()method.voidwrite(char[] cbuf)Invokes the delegate'swrite(char[])method.voidwrite(char[] cbuf, int off, int len)Invokes the delegate'swrite(char[], int, int)method.voidwrite(int c)Invokes the delegate'swrite(int)method.voidwrite(String str)Invokes the delegate'swrite(String)method.voidwrite(String str, int off, int len)Invokes the delegate'swrite(String)method.-
Methods inherited from class java.io.Writer
nullWriter
-
-
-
-
Constructor Detail
-
ProxyWriter
public ProxyWriter(Writer proxy)
Constructs a new ProxyWriter.- Parameters:
proxy- the Writer to delegate to
-
-
Method Detail
-
append
public Writer append(char c) throws IOException
Invokes the delegate'sappend(char)method.- Specified by:
appendin interfaceAppendable- Overrides:
appendin classWriter- 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, int start, int end) throws IOException
Invokes the delegate'sappend(CharSequence, int, int)method.- Specified by:
appendin interfaceAppendable- Overrides:
appendin classWriter- Parameters:
csq- The character sequence to writestart- The index of the first character to writeend- The index of the first character to write (exclusive)- 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'sappend(CharSequence)method.- Specified by:
appendin interfaceAppendable- Overrides:
appendin classWriter- Parameters:
csq- The character sequence to write- Returns:
- this writer
- Throws:
IOException- if an I/O error occurs.- Since:
- 2.0
-
write
public void write(int c) throws IOExceptionInvokes the delegate'swrite(int)method.- Overrides:
writein classFilterWriter- Parameters:
c- the character to write- Throws:
IOException- if an I/O error occurs.
-
write
public void write(char[] cbuf) throws IOExceptionInvokes the delegate'swrite(char[])method.- Overrides:
writein classWriter- 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 IOExceptionInvokes the delegate'swrite(char[], int, int)method.- Overrides:
writein classFilterWriter- Parameters:
cbuf- the characters to writeoff- The start offsetlen- The number of characters to write- Throws:
IOException- if an I/O error occurs.
-
write
public void write(String str) throws IOException
Invokes the delegate'swrite(String)method.- Overrides:
writein classWriter- 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'swrite(String)method.- Overrides:
writein classFilterWriter- Parameters:
str- the string to writeoff- The start offsetlen- The number of characters to write- Throws:
IOException- if an I/O error occurs.
-
flush
public void flush() throws IOExceptionInvokes the delegate'sflush()method.- Specified by:
flushin interfaceFlushable- Overrides:
flushin classFilterWriter- Throws:
IOException- if an I/O error occurs.
-
close
public void close() throws IOExceptionInvokes the delegate'sclose()method.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Overrides:
closein classFilterWriter- Throws:
IOException- if an I/O error occurs.
-
-