Class StreamGobbler

  • All Implemented Interfaces:
    java.lang.Runnable

    public class StreamGobbler
    extends java.lang.Thread
    Class that gobbles content from (optionally saving it) an input stream.
    Author:
    Sam Adams
    • Nested Class Summary

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

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

      • Fields inherited from class java.lang.Thread

        MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
    • Constructor Summary

      Constructors 
      Constructor Description
      StreamGobbler​(java.io.InputStream in)  
      StreamGobbler​(java.io.InputStream in, java.io.OutputStream out)
      Constructs StreamGobbler, and starts thread.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      byte[] getCachedBytes()  
      java.lang.Exception getError()  
      boolean isError()  
      boolean isStarted()
      Returns true if the StreamGobbler has been started (even if it has now finished), and otherwise false.
      void run()
      Reads content from input stream, until either the end of the stream is reached, or the thread is interrupted.
      void setCacheSize​(int n)  
      • 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
    • Constructor Detail

      • StreamGobbler

        public StreamGobbler​(java.io.InputStream in,
                             java.io.OutputStream out)
        Constructs StreamGobbler, and starts thread.
        Parameters:
        in -
        save -
        threadName -
      • StreamGobbler

        public StreamGobbler​(java.io.InputStream in)
    • Method Detail

      • setCacheSize

        public void setCacheSize​(int n)
      • run

        public void run()
        Reads content from input stream, until either the end of the stream is reached, or the thread is interrupted.
        Specified by:
        run in interface java.lang.Runnable
        Overrides:
        run in class java.lang.Thread
      • isStarted

        public boolean isStarted()
        Returns true if the StreamGobbler has been started (even if it has now finished), and otherwise false.
        Returns:
      • getCachedBytes

        public byte[] getCachedBytes()
      • isError

        public boolean isError()
      • getError

        public java.lang.Exception getError()