@SuppressWarnings("UseOfSystemOutOrSystemErr")
    public static StandardOutput parse(final String stdout, final boolean discardNone) throws IOException {
        if (stdout == null) {
            return new StandardOutput(Target.INHERIT, null, Redirect.INHERIT, null);
        }
        final Target target;
        Path stdoutPath = null;
        final OutputStream out;
        final String value = stdout.trim().toLowerCase(Locale.ENGLISH);
        if ("system.out".equals(value)) {
            target = Target.SYSTEM_OUT;
            out = System.out;
        } else if ("system.err".equals(value)) {
            target = Target.SYSTEM_ERR;
            out = System.err;
        } else if ("none".equals(value)) {
            if (discardNone) {
                target = Target.DISCARDING;
                out = DISCARDING;
            } else {
                target = Target.COLLECTING;
                out = new ByteArrayOutputStream();
            }
        } else {
            // Attempt to create a file
            stdoutPath = Paths.get(stdout.trim());
            if (Files.notExists(stdoutPath)) {
                final Path parent = stdoutPath.getParent();
                if (parent != null) {
                    Files.createDirectories(parent);
                }
                Files.createFile(stdoutPath);
            }
            target = Target.FILE;
            out = null;
        }
        Redirect destination = null;
        if (stdoutPath != null) {
            destination = Redirect.to(stdoutPath.toFile());
        }
        return new StandardOutput(target, out, destination, stdoutPath);
    }
@ SuppressWarnings ( "UseOfSystemOutOrSystemErr" ) public static StandardOutput parse ( final String stdout , final boolean discardNone ) throws IOException { if ( stdout == null ) { return new StandardOutput ( Target . INHERIT , null , Redirect . INHERIT , null ) ; } final Target target ; Path stdoutPath = null ; final OutputStream out ; final String value = stdout . trim ( ) . toLowerCase ( Locale . ENGLISH ) ; if ( "system.out" . equals ( value ) ) { target = Target . SYSTEM_OUT ; out = System . out ; } else if ( "system.err" . equals ( value ) ) { target = Target . SYSTEM_ERR ; out = System . err ; } else if ( "none" . equals ( value ) ) { if ( discardNone ) { target = Target . DISCARDING ; out = DISCARDING ; } else { target = Target . COLLECTING ; out = new ByteArrayOutputStream ( ) ; } } else { stdoutPath = Paths . get ( stdout . trim ( ) ) ; if ( Files . notExists ( stdoutPath ) ) { final Path parent = stdoutPath . getParent ( ) ; if ( parent != null ) { Files . createDirectories ( parent ) ; } Files . createFile ( stdoutPath ) ; } target = Target . FILE ; out = null ; } Redirect destination = null ; if ( stdoutPath != null ) { destination = Redirect . to ( stdoutPath . toFile ( ) ) ; } return new StandardOutput ( target , out , destination , stdoutPath ) ; }
Parses the string and attempts to determine where the data for the stream should be written. The following are
the options for the value:
<ul>
<li>{@code none} indicates the data for this stream will be consumed and {@link #toString()} will return the
data of the {@code discardNone} parameter is {@code false}, otherwise the data will be discarded</li>
<li>{@code System.out} or {@code System.err} to write to the respective stream</li>
<li>Any other value is assumed to be the path to a file and the data will written to the file</li>
</ul>

@param stdout      the value to be parsed
@param discardNone {@code true} if the {@code stdout} value is {@code none} and the data should be discarded,
otherwise the data will be consumed if the {@code stdout} value is {@code none} and will be
available via {@link #toString()}

@return a new output stream

@throws IOException if there is an error creating the stream