O'Reilly logo

Java 9 Cookbook by Nick Samoylov, Mohamed Sanaulla

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

How it works...

The startPipeline() method starts a Process for each ProcessBuilder object in the list. Except for the first and the last processes, it redirects the output of one process to the input of another process by using ProcessBuilder.Redirect.PIPE. If you have provided redirectOutput for any intermediate process as something other than ProcessBuilder.Redirect.PIPE, then there will be an error thrown, something similar to the following: 

Exception in thread "main" java.lang.IllegalArgumentException: builder redirectOutput() must be PIPE except for the last builder: INHERIT. 

It states that any builder except for the last should redirect its output to the next process. The same is applicable for redirectInput.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required