Class StreamGobbler

  • All Implemented Interfaces:
    Runnable

    public final class StreamGobbler
    extends Thread
    • Constructor Detail

      • StreamGobbler

        public StreamGobbler​(InputStream is)
      • StreamGobbler

        public StreamGobbler​(InputStream inputStream,
                             @Nullable
                             Integer maxAcceptedOutputSize,
                             @NotNull
                             String commandDebug)
        Parameters:
        maxAcceptedOutputSize - maximum threshold of the data in stream (in bytes), which will be read. If output size is larger, further output will be ignored. Default - null - no limit.
        commandDebug - debug text for error messages from this StreamCobbler
    • Method Detail

      • notifyProcessExit

        public void notifyProcessExit()
      • run

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

        public String getReadString​(Charset encoding)
        Returns:
        content collected by this StreamGobbler as a string with given encoding
      • isOutputOverload

        public boolean isOutputOverload()
        Return true if not whole content was recorded, due to its large size
      • getReadBytes

        public byte[] getReadBytes()
        Returns:
        content collected by this StreamGobbler as bytes
      • getLastActivityTimestamp

        public long getLastActivityTimestamp()
        Returns:
        System.currentTimeMillis for the last moment when data was detected in output stream
      • getReadLength

        public long getReadLength()
      • getCommandDebug

        @NotNull
        public String getCommandDebug()