English | Site Directory

Android - An Open Handset Alliance Project

java.lang
public final class

java.lang.ProcessBuilder

java.lang.Object
java.lang.ProcessBuilder

A builder for creating OS-specific processes.

Summary

Public Constructors

          ProcessBuilder(String[] command)

Constructs an instance with the given command.

          ProcessBuilder(List command)

Constructs an instance with the given command.

Public Methods

        ProcessBuilder  command(String[] command)

Changes the program and arguments to the command given.

        ProcessBuilder  command(List command)

Changes the program and arguments to the command given.

        List  command()

The builder's current program and arguments.

        ProcessBuilder  directory(File directory)

Changes the working directory to the directory given.

        File  directory()

The working directory that's currently set.

        Map  environment()

The builder's current environment.

        ProcessBuilder  redirectErrorStream(boolean redirectErrorStream)

Changes the state of whether or not standard error is redirected.

        boolean  redirectErrorStream()

Indicates whether or not the standard error should be redirected to standard output.

        Process  start()

Starts a new process based on the current state of the builder.

Methods inherited from class java.lang.Object

Details

Public Constructors

public ProcessBuilder(String[] command)

Constructs an instance with the given command.

Parameters

command The program and arguments.

public ProcessBuilder(List command)

Constructs an instance with the given command.

Parameters

command The program and arguments.

Throws

NullPointerException if command is null.

Public Methods

public ProcessBuilder command(String[] command)

Changes the program and arguments to the command given.

Parameters

command The program and arguments.

Returns

  • A reference to this instance.

public ProcessBuilder command(List command)

Changes the program and arguments to the command given. The list passed is not copied, so any subsequent updates to it are reflected in this instance's state.

Parameters

command The program and arguments.

Returns

  • A reference to this instance.

Throws

NullPointerException if command is null.

public List command()

The builder's current program and arguments. The returned value is considered live and modifications to it will change the state of the instance.

Returns

  • The program and arguments currently set.

public ProcessBuilder directory(File directory)

Changes the working directory to the directory given. If the given directory is null, then the working directory of the Java process is used when a process is started.

Parameters

directory The working directory to set.

Returns

  • A reference to this instance.

public File directory()

The working directory that's currently set. If this value is null, then the working directory of the Java process is used.

Returns

  • The current working directory, which may be null.

public Map environment()

The builder's current environment. When an instance is created, the environment is populated with a copy of the environment, as returned by getenv(). The Map returned is live and any changes made to it are reflected in this instance's state.

Returns

  • The Map of the current environment variables.

public ProcessBuilder redirectErrorStream(boolean redirectErrorStream)

Changes the state of whether or not standard error is redirected.

Parameters

redirectErrorStream true to redirect standard error, false if not.

Returns

  • A reference to this instance.

public boolean redirectErrorStream()

Indicates whether or not the standard error should be redirected to standard output. If redirected, the getErrorStream() will always return end of stream and standard error is written to getInputStream().

Returns

  • Indicates whether or not standard error is redirected.

public Process start()

Starts a new process based on the current state of the builder.

Returns

  • The new process that was started.

Throws

NullPointerException if any of the elements of command() are null.
IndexOutOfBoundsException if command() is empty.
SecurityException if checkExec(String) doesn't allow process creation.
IOException if an I/O error happens.
Build m5-rc15i - 10 Jun 2008 13:54