Class StandardOutput


  • public class StandardOutput
    extends Object
    Information on how the stdout should be consumed.
    Author:
    James R. Perkins
    • Method Detail

      • parse

        public static StandardOutput parse​(String stdout,
                                           boolean discardNone)
                                    throws IOException
        Parses the string and attempts to determine where the data for the stream should be written. The following are the options for the value:
        • none indicates the data for this stream will be consumed and toString() will return the data of the discardNone parameter is false, otherwise the data will be discarded
        • System.out or System.err to write to the respective stream
        • Any other value is assumed to be the path to a file and the data will written to the file
        Parameters:
        stdout - the value to be parsed
        discardNone - true if the stdout value is none and the data should be discarded, otherwise the data will be consumed if the stdout value is none and will be available via toString()
        Returns:
        a new output stream
        Throws:
        IOException - if there is an error creating the stream
      • parse

        public static StandardOutput parse​(String stdout,
                                           boolean discardNone,
                                           boolean append)
                                    throws IOException
        Parses the string and attempts to determine where the data for the stream should be written.The following are the options for the value:
        • none indicates the data for this stream will be consumed and toString() will return the data of the discardNone parameter is false, otherwise the data will be discarded
        • System.out or System.err to write to the respective stream
        • Any other value is assumed to be the path to a file and the data will written to the file
        Parameters:
        stdout - the value to be parsed
        discardNone - true if the stdout value is none and the data should be discarded, otherwise the data will be consumed if the stdout value is none and will be available via toString()
        append - If stdout is a file, append output to existing file if true, otherwise a new file is created.
        Returns:
        a new output stream
        Throws:
        IOException - if there is an error creating the stream
      • isFile

        public static boolean isFile​(String output)
      • startConsumer

        public Optional<Thread> startConsumer​(Process process)
        If the processes stdout should be consumed a thread which consumes it will be started.
        Parameters:
        process - the process to possibly start the thread for
        Returns:
        the optional thread
      • getStdoutPath

        public Path getStdoutPath()
        The path to the file where the data was written.
        Returns:
        the path to where the data was written, otherwise {@link null} if the data was not written to a file.
      • getTarget

        public StandardOutput.Target getTarget()
        The target the data was written to.
        Returns:
        the target