org.apache.commons.io.output

Class ProxyOutputStream

    • Constructor Detail

      • ProxyOutputStream

        public ProxyOutputStream(OutputStream proxy)
        Constructs a new ProxyOutputStream.
        Parameters:
        proxy - the OutputStream to delegate to
    • Method Detail

      • write

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

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

        public void write(byte[] bts,
                          int st,
                          int end)
                   throws IOException
        Invokes the delegate's write(byte[]) method.
        Overrides:
        write in class  FilterOutputStream
        Parameters:
        bts - the bytes to write
        st - The start offset
        end - The number of bytes 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 bytes to be written (1 for the write(int) method, buffer length for write(byte[]), 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 bytes 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 bytes written (1 for the write(int) method, buffer length for write(byte[]), 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 bytes 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 behavior is to re-throw the exception.

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

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