I\'m trying to use Java\'s ProcessBuilder class to execute a command that has a pipe in it. For example:
ls -l | grep foo
How
The simplest way is to invoke the shell with the command line as the parameter. After all, it's the shell which is interpreting "|" to mean "pipe the data between two processes".
Alternatively, you could launch each process separately, and read from the standard output of "ls -l", writing the data to the standard input of "grep" in your example.