Class FileCopyRunnable

  • All Implemented Interfaces:
    Runnable

    public class FileCopyRunnable
    extends Object
    implements Runnable
    Runnable implementation that copies data from an input stream to an output stream when executed. This is useful when executing external processes since reading and writing to their stdin and stdout is best done with separate thread.
    Since:
    2.15
    Author:
    nicklas
    Last modified
    $Date $
    • Constructor Detail

      • FileCopyRunnable

        public FileCopyRunnable​(InputStream in,
                                OutputStream out)
        Create a new file copy object. The stream are automatically closed in case of an error
        Parameters:
        in - The input stream to read data from (required)
        out - The output stream to write data to (optional; if not given the input stream is read and then discarded)
    • Method Detail

      • run

        public void run()
        Specified by:
        run in interface Runnable
      • hasError

        public boolean hasError()
        A boolean flag indicating if the copying was sucessful or not. This method should only be called after the thread has ended.
        See Also:
        getError()
      • getError

        public Throwable getError()
        Get the exception that was thrown when executing the file copy operation. This method should only be called after the thread has ended.
        Returns:
        An error or null if the operation was sucessful
        See Also:
        hasError()