Class InputStreamDrainer

  • All Implemented Interfaces:
    java.lang.Runnable

    public final class InputStreamDrainer
    extends java.lang.Thread
    Will drain the output stream.
    • Nested Class Summary

      • Nested classes/interfaces inherited from class java.lang.Thread

        java.lang.Thread.State, java.lang.Thread.UncaughtExceptionHandler
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private static int BUF_SIZE  
      private java.io.InputStream in  
      private java.util.List<java.io.OutputStream> outs  
      • Fields inherited from class java.lang.Thread

        MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
    • Constructor Summary

      Constructors 
      Constructor Description
      InputStreamDrainer​(java.io.InputStream in)
      Create a drainer which will discard the read lines.
      InputStreamDrainer​(java.io.InputStream in, java.io.OutputStream out)
      Create a drainer that will echo all read lines to out.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void addOutputStream​(java.io.OutputStream out)
      Adds an output stream to drain the output to.
      void run()
      Drain the stream.
      • Methods inherited from class java.lang.Thread

        activeCount, checkAccess, clone, countStackFrames, currentThread, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, onSpinWait, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, suspend, toString, yield
      • Methods inherited from class java.lang.Object

        equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Field Detail

      • outs

        private final java.util.List<java.io.OutputStream> outs
      • in

        private final java.io.InputStream in
    • Constructor Detail

      • InputStreamDrainer

        public InputStreamDrainer​(java.io.InputStream in)
        Create a drainer which will discard the read lines.
        Parameters:
        in - The input stream to drain
      • InputStreamDrainer

        public InputStreamDrainer​(java.io.InputStream in,
                                  java.io.OutputStream out)
        Create a drainer that will echo all read lines to out.
        Parameters:
        in - The input stream to drain
        out - Where to drain the stream into
    • Method Detail

      • addOutputStream

        public void addOutputStream​(java.io.OutputStream out)
        Adds an output stream to drain the output to.
        Parameters:
        out - The output stream
      • run

        public void run()
        Drain the stream.
        Specified by:
        run in interface java.lang.Runnable
        Overrides:
        run in class java.lang.Thread