Class CLIProcessManager


  • public class CLIProcessManager
    extends java.lang.Object
    CLI Utils class
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static long countLinesUntilStringOccurs​(java.lang.Process process, java.lang.String successString, java.lang.String errorString)
      Count and returns the no.
      static java.lang.Process createProcess​(java.lang.String command)
      Creates a process
      static java.util.List<java.lang.Process> createProcesses​(int n, java.lang.String command)
      Create n processes of the same command
      static java.lang.Process destroyAndCreateNewProcess​(java.lang.Process process, java.lang.String command)
      Short handler for destroyProcess and createProcess
      static void destroyProcess​(java.lang.Process process)
      Destroys a process forcibly
      static void executeCommand​(java.lang.Process process, java.lang.String command)  
      static boolean isReaderReady​(java.lang.Process process)
      Checks if the process input stream is ready to be read.
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • CLIProcessManager

        public CLIProcessManager()
    • Method Detail

      • createProcess

        public static java.lang.Process createProcess​(java.lang.String command)
        Creates a process
        Parameters:
        command -
        Returns:
      • destroyProcess

        public static void destroyProcess​(java.lang.Process process)
        Destroys a process forcibly
        Parameters:
        process -
      • destroyAndCreateNewProcess

        public static java.lang.Process destroyAndCreateNewProcess​(java.lang.Process process,
                                                                   java.lang.String command)
        Short handler for destroyProcess and createProcess
        Parameters:
        process -
        command -
        Returns:
      • createProcesses

        public static java.util.List<java.lang.Process> createProcesses​(int n,
                                                                        java.lang.String command)
        Create n processes of the same command
        Parameters:
        n - the amount of processes created
        command - the command to create the process with
        Returns:
      • countLinesUntilStringOccurs

        public static long countLinesUntilStringOccurs​(java.lang.Process process,
                                                       java.lang.String successString,
                                                       java.lang.String errorString)
                                                throws java.io.IOException
        Count and returns the no. of lines of one process until a certain string appears,
        Parameters:
        process -
        successString - the string of the process after the no of line should be returned
        errorString - the error string, will throw an IOException if this appeared.
        Returns:
        Throws:
        java.io.IOException
      • executeCommand

        public static void executeCommand​(java.lang.Process process,
                                          java.lang.String command)
                                   throws java.io.IOException
        Throws:
        java.io.IOException
      • isReaderReady

        public static boolean isReaderReady​(java.lang.Process process)
                                     throws java.io.IOException
        Checks if the process input stream is ready to be read.
        Parameters:
        process -
        Returns:
        Throws:
        java.io.IOException