ProcessBuilder class in Java

java.lang.ProcessBuilder

This class is used to create operating system processes.

Each ProcessBuilder instance manages a collection of process attributes. The start() method creates a new Process instance with those attributes. The start() method can be invoked repeatedly from the same instance to create new subprocesses with identical or related attributes.

The startPipeline method can be invoked to create a pipeline of new processes that send the output of each process directly to the next process. Each process has the attributes of its respective ProcessBuilder.

Some methods of ProcessBuilder class

ProcessBuilder.ProcessBuilder(String...)This method constructs a process builder with the specified operating system program and arguments.

ProcessBuilder.ProcessBuilder(List<String>)This method constructs a process builder with the specified operating system program and arguments.

command()This method returns this process builder's operating system program and arguments.

command(List<String>)This method sets this process builder's operating system program and arguments.

command(String...)This method sets this process builder's operating system program and arguments. 

directory()This method returns this process builder's working directory.

directory(File)This method sets this process builder's working directory.

environment()This method returns a string map view of this process builder's environment.

inheritIO()This method sets the source and destination for subprocess standard I/O to be the same as those of the current Java process.

redirectError()This method returns this process builder's standard error destination.

redirectError(File)This method sets this process builder's standard error destination to a file.

redirectError(Redirect)This method sets this process builder's standard error destination.

redirectErrorStream()This method tells whether this process builder merges standard error and standard output.

redirectErrorStream(boolean)This method sets this process builder's redirectErrorStream property.

redirectInput()This method returns this process builder's standard input source.

redirectInput(File)This method sets this process builder's standard input source to a file.

redirectInput(Redirect)This method sets this process builder's standard input source.

redirectOutput()This method returns this process builder's standard output destination.

redirectOutput(File)This method sets this process builder's standard output destination to a file.

redirectOutput(Redirect)This method sets this process builder's standard output destination.

start()This method starts a new process using the attributes of this process builder.

ProcessBuilder.startPipeline(List<ProcessBuilder>)his method starts a Process for each ProcessBuilder, creating a pipeline of processes linked by their standard output and standard input streams.

No comments:

Post a Comment