public abstract class Command extends Object
Examples:
pipe("ls").through("cat").to("sed", "-e", "s/e//g");
from(new File("foo.txt")).through("sort").to("sed", "-e", "s/e//g");
from(new File("foo.txt")).through("sort").to(new File("foo2.txt"));
| Constructor and Description |
|---|
Command() |
| Modifier and Type | Method and Description |
|---|---|
static Command |
from(File inputFile)
Creates and returns a
Command object which reads from the inputFile |
static Command |
pipe(String... command)
Creates and returns a
Command object which will execute the given command and catch its
output. |
void |
print()
Prints the output to
System.out. |
static int |
run(ProcessBuilder.Redirect redirectError,
String... command)
Executes the command, without redirecting its input or output.
|
static int |
run(String... command)
Executes the command, without redirecting its input, output and error.
|
protected abstract InputStream |
start() |
Command |
through(String... command)
|
void |
to(File outputFile)
Executes this
Command, catches its output and stores it in the outputFile. |
int |
to(ProcessBuilder.Redirect redirectError,
String... command)
Executes this
Command, catches its output and feeds it into the command. |
int |
to(String... command)
Executes this
Command, catches its output and feeds it into the command. |
public static int run(String... command) throws InterruptedException, IOException
InterruptedExceptionIOExceptionpublic static int run(ProcessBuilder.Redirect redirectError, String... command) throws InterruptedException, IOException
redirectError - Where to redirect the error output of the commandInterruptedExceptionIOExceptionpublic static Command from(File inputFile)
Command object which reads from the inputFileCommandpublic static Command pipe(String... command)
Command object which will execute the given command and catch its
output.Commandpublic void print()
throws IOException
System.out.IOExceptionCommandpublic int to(String... command) throws InterruptedException, IOException
Command, catches its output and feeds it into the command.InterruptedExceptionIOExceptionCommandpublic int to(ProcessBuilder.Redirect redirectError, String... command) throws InterruptedException, IOException
Command, catches its output and feeds it into the command.redirectError - Where to redirect the error output of the commandInterruptedExceptionIOExceptionCommandpublic void to(File outputFile) throws IOException
Command, catches its output and stores it in the outputFile.IOExceptionCommandpublic Command through(String... command) throws InterruptedException, IOException
Command object which will execute this Command, catch its
output, feed it through the given command and catch its output.InterruptedExceptionIOExceptionCommandprotected abstract InputStream start() throws IOException
CommandIOExceptionCopyright © 2016. All rights reserved.