public class CommandRunner extends Object
| Modifier and Type | Class and Description | 
|---|---|
| static interface  | CommandRunner.Consumer<T>Version of java.util.function.Consumer that can throw checked exceptions. | 
| Constructor and Description | 
|---|
| CommandRunner(String... command) | 
| Modifier and Type | Method and Description | 
|---|---|
| CommandRunner | consumeError(CommandRunner.Consumer<InputStream> consumer) | 
| CommandRunner | consumeError(org.slf4j.Logger logger) | 
| CommandRunner | consumeOutput(CommandRunner.Consumer<InputStream> consumer) | 
| CommandRunner | feedInput(byte[] bytes) | 
| CommandRunner | feedInput(CommandRunner.Consumer<OutputStream> feeder) | 
| int | run()Run the command and wait for the process to finish. | 
| static int | run(String... command) | 
| int | run(Supplier<Long> timeout) | 
public CommandRunner(String... command)
public CommandRunner consumeOutput(CommandRunner.Consumer<InputStream> consumer)
consumer - The normal output of the subprocess is passes as an InputStream to this object.
                 If null, the stream is discarded.public CommandRunner consumeError(CommandRunner.Consumer<InputStream> consumer)
consumer - The error output of the subprocess is passed as an InputStream to this object.
                 If null, the stream is discarded.public CommandRunner consumeError(org.slf4j.Logger logger)
logger - If the subprocess generated error output, write it to this Logger object.public CommandRunner feedInput(CommandRunner.Consumer<OutputStream> feeder)
feeder - The normal input of the subprocess is passed as an OutputStream to this object.public CommandRunner feedInput(byte[] bytes)
bytes - These bytes are written to the normal input of the subprocess.public int run()
        throws InterruptedException,
               Throwable
InterruptedException - if the current thread is interrupted while the process is runningThrowablepublic int run(Supplier<Long> timeout) throws TimeoutException, InterruptedException, Throwable
Copyright © 2010–2025 The DAISY Consortium. All rights reserved.