Class StreamCopyThread

  • All Implemented Interfaces:
    Runnable

    public class StreamCopyThread
    extends Thread
    Thread to copy from an input stream to an output stream.
    • Constructor Detail

      • StreamCopyThread

        public StreamCopyThread​(InputStream i,
                                OutputStream o)
        Create a thread to copy data from an input stream to an output stream.
        Parameters:
        i - stream to copy from. The thread terminates when this stream reaches EOF. The thread closes this stream before it exits.
        o - stream to copy into. The destination stream is automatically closed when the thread terminates.
    • Method Detail

      • halt

        public void halt()
                  throws InterruptedException
        Request that the thread terminate, and wait for it.

        This method signals to the copy thread that it should stop as soon as there is no more IO occurring.

        Throws:
        InterruptedException - the calling thread was interrupted.
      • run

        public void run()
        Specified by:
        run in interface Runnable
        Overrides:
        run in class Thread