Class ReaderWriterPipeThread

  • All Implemented Interfaces:
    Runnable

    public final class ReaderWriterPipeThread
    extends Thread
    A Thread that moves data from a Reader to a Writer.
    Author:
    Kim Hansen
    • Field Detail

      • LOG

        private static final org.apache.commons.logging.Log LOG
      • BUF

        private static final char[] BUF
      • reader

        private final Reader reader
      • writer

        private Writer writer
    • Constructor Detail

      • ReaderWriterPipeThread

        private ReaderWriterPipeThread​(Reader reader,
                                       Writer writer)
        Parameters:
        reader -
        writer - may be null TBC: does this make sense?
    • Method Detail

      • instantiate

        public static ReaderWriterPipeThread instantiate​(Reader reader,
                                                         Writer writer)
        Will create a thread that reads from reader and writes to write until reader reaches EOF. Then the thread will close. Remember to join() this thread before closing reader or writer.
        Parameters:
        reader -
        writer - may be null TBC: does this make sense?
        Returns:
        Returns the new thread
      • run

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

        public void setWriter​(Writer writer)
        Parameters:
        writer - the writer to set This may be null TBC
      • close

        public void close()
        Close the thread.