org.apache.commons.io.output

Class ProxyWriter

  • All Implemented Interfaces:
    Closeable, Flushable, Appendable, AutoCloseable


    public class ProxyWriterextends 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).
    Version:
    $Id: ProxyWriter.java 1415850 2012-11-30 20:51:39Z ggregory $
    • Constructor Summary

      Constructors 
      Constructor and Description
      ProxyWriter(Writer proxy)
      Constructs a new ProxyWriter.
    • Method Summary

      Methods 
      Modifier and TypeMethod and Description
      protected voidafterWrite(int n)
      Invoked by the write methods after the proxied call has returned successfully.
      Writerappend(char c)
      Invokes the delegate's append(char) method.
      Writerappend(CharSequence csq)
      Invokes the delegate's append(CharSequence) method.
      Writerappend(CharSequence csq, int start, int end)
      Invokes the delegate's append(CharSequence, int, int) method.
      protected voidbeforeWrite(int n)
      Invoked by the write methods before the call is proxied.
      voidclose()
      Invokes the delegate's close() method.
      voidflush()
      Invokes the delegate's flush() method.
      protected voidhandleIOException(IOException e)
      Handle any IOExceptions thrown.
      voidwrite(char[] chr)
      Invokes the delegate's write(char[]) method.
      voidwrite(char[] chr, int st, int len)
      Invokes the delegate's write(char[], int, int) method.
      voidwrite(int idx)
      Invokes the delegate's write(int) method.
      voidwrite(String str)
      Invokes the delegate's write(String) method.
      voidwrite(String str, int st, int len)
      Invokes the delegate's write(String) method.
    • 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'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,            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
      • write

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

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

        public void write(char[] chr,         int st,         int len)           throws IOException
        Invokes the delegate's write(char[], int, int) method.
        Overrides:
        write in class FilterWriter
        Parameters:
        chr - the characters to write
        st - The start offset
        len - 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'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 st,         int len)           throws IOException
        Invokes the delegate's write(String) method.
        Overrides:
        write in class FilterWriter
        Parameters:
        str - the string to write
        st - The start offset
        len - The number of characters to write
        Throws:
        IOException - if an I/O error occurs
      • beforeWrite

        protected void beforeWrite(int n)                    throws IOException
        Invoked by the write methods before the call is proxied. The number of chars to be written (1 for the write(int) method, buffer length for write(char[]), etc.) is given as an argument.

        Subclasses can override this method to add common pre-processing functionality without having to override all the write methods. The default implementation does nothing.

        Parameters:
        n - number of chars to be written
        Throws:
        IOException - if the pre-processing fails
        Since:
        2.0
      • afterWrite

        protected void afterWrite(int n)                   throws IOException
        Invoked by the write methods after the proxied call has returned successfully. The number of chars written (1 for the write(int) method, buffer length for write(char[]), etc.) is given as an argument.

        Subclasses can override this method to add common post-processing functionality without having to override all the write methods. The default implementation does nothing.

        Parameters:
        n - number of chars written
        Throws:
        IOException - if the post-processing fails
        Since:
        2.0
      • handleIOException

        protected void handleIOException(IOException e)                          throws IOException
        Handle any IOExceptions thrown.

        This method provides a point to implement custom exception handling. The default behaviour is to re-throw the exception.

        Parameters:
        e - The IOException thrown
        Throws:
        IOException - if an I/O error occurs
        Since:
        2.0

Copyright © 2002–2016 The Apache Software Foundation. All rights reserved.



NOTHING
NOTHING
Add the Maven Dependecy to your project: maven dependecy for com.amazonaws : aws-java-sdk : 1.3.14