Class GProcessOutputCollectorTask

java.lang.Object
com.glitchybyte.glib.concurrent.GTask
com.glitchybyte.glib.process.GProcessOutputCollectorTask
All Implemented Interfaces:
Runnable

public final class GProcessOutputCollectorTask extends GTask
Console output collector for capturing an external process output.

This class uses a buffer to accumulate lines, when lines are requested the whole buffer is returned and a new buffer created for new lines.

  • Constructor Details

    • GProcessOutputCollectorTask

      public GProcessOutputCollectorTask(Process process, int maxOutputBufferLines)
      Creates an output collector.
      Parameters:
      process - Process to which attach this collector.
      maxOutputBufferLines - Max lines to hold in memory. If output exceeds this quantity before being queried, older lines will be lost. A value of zero will prevent any collection.
  • Method Details

    • run

      public void run()
      Collector runner. This must be called on a different thread.
    • getOutput

      public List<String> getOutput()
      Returns all collected output until this moment. Recreate collection buffer.
      Returns:
      All collected lines until this moment.