# ProcessBuilder.Redirect

Added in[API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  
Summary:[Fields](https://developer.android.com/reference/java/lang/ProcessBuilder.Redirect#lfields)\|[Methods](https://developer.android.com/reference/java/lang/ProcessBuilder.Redirect#pubmethods)\|[Inherited Methods](https://developer.android.com/reference/java/lang/ProcessBuilder.Redirect#inhmethods)  

# ProcessBuilder.Redirect

`
public
static

abstract
class
ProcessBuilder.Redirect
`  
`

extends `[Object](https://developer.android.com/reference/java/lang/Object)`


``


`

|---|-----------------------------------|
| [java.lang.Object](https://developer.android.com/reference/java/lang/Object) ||
| ↳ | java.lang.ProcessBuilder.Redirect |

<br />

*** ** * ** ***

Represents a source of subprocess input or a destination of subprocess output. Each`Redirect`instance is one of the following:

- the special value[Redirect.PIPE](https://developer.android.com/reference/java/lang/ProcessBuilder.Redirect#PIPE)
- the special value[Redirect.INHERIT](https://developer.android.com/reference/java/lang/ProcessBuilder.Redirect#INHERIT)
- a redirection to read from a file, created by an invocation of[Redirect.from(File)](https://developer.android.com/reference/java/lang/ProcessBuilder.Redirect#from(java.io.File))
- a redirection to write to a file, created by an invocation of[Redirect.to(File)](https://developer.android.com/reference/java/lang/ProcessBuilder.Redirect#to(java.io.File))
- a redirection to append to a file, created by an invocation of[Redirect.appendTo(File)](https://developer.android.com/reference/java/lang/ProcessBuilder.Redirect#appendTo(java.io.File))

Each of the above categories has an associated unique[Type](https://developer.android.com/reference/java/lang/ProcessBuilder.Redirect.Type).

## Summary

|                                                                                                                                                           ### Fields                                                                                                                                                            ||
|-----------------------------------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| ` public static final `[ProcessBuilder.Redirect](https://developer.android.com/reference/java/lang/ProcessBuilder.Redirect) | [INHERIT](https://developer.android.com/reference/java/lang/ProcessBuilder.Redirect#INHERIT) Indicates that subprocess I/O source or destination will be the same as those of the current process. |
| ` public static final `[ProcessBuilder.Redirect](https://developer.android.com/reference/java/lang/ProcessBuilder.Redirect) | [PIPE](https://developer.android.com/reference/java/lang/ProcessBuilder.Redirect#PIPE) Indicates that subprocess I/O will be connected to the current Java process over a pipe.                    |

|                                                                                                                                                                                     ### Public methods                                                                                                                                                                                     ||
|----------------------------------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| ` static `[ProcessBuilder.Redirect](https://developer.android.com/reference/java/lang/ProcessBuilder.Redirect)             | ` `[appendTo](https://developer.android.com/reference/java/lang/ProcessBuilder.Redirect#appendTo(java.io.File))`(`[File](https://developer.android.com/reference/java/io/File)` file) ` Returns a redirect to append to the specified file.                    |
| ` boolean`                                                                                                                 | ` `[equals](https://developer.android.com/reference/java/lang/ProcessBuilder.Redirect#equals(java.lang.Object))`(`[Object](https://developer.android.com/reference/java/lang/Object)` obj) ` Compares the specified object with this`Redirect`for equality.    |
| ` `[File](https://developer.android.com/reference/java/io/File)                                                            | ` `[file](https://developer.android.com/reference/java/lang/ProcessBuilder.Redirect#file())`() ` Returns the[File](https://developer.android.com/reference/java/io/File)source or destination associated with this redirect, or`null`if there is no such file. |
| ` static `[ProcessBuilder.Redirect](https://developer.android.com/reference/java/lang/ProcessBuilder.Redirect)             | ` `[from](https://developer.android.com/reference/java/lang/ProcessBuilder.Redirect#from(java.io.File))`(`[File](https://developer.android.com/reference/java/io/File)` file) ` Returns a redirect to read from the specified file.                            |
| ` int`                                                                                                                     | ` `[hashCode](https://developer.android.com/reference/java/lang/ProcessBuilder.Redirect#hashCode())`() ` Returns a hash code value for this`Redirect`.                                                                                                         |
| ` static `[ProcessBuilder.Redirect](https://developer.android.com/reference/java/lang/ProcessBuilder.Redirect)             | ` `[to](https://developer.android.com/reference/java/lang/ProcessBuilder.Redirect#to(java.io.File))`(`[File](https://developer.android.com/reference/java/io/File)` file) ` Returns a redirect to write to the specified file.                                 |
| ` abstract `[ProcessBuilder.Redirect.Type](https://developer.android.com/reference/java/lang/ProcessBuilder.Redirect.Type) | ` `[type](https://developer.android.com/reference/java/lang/ProcessBuilder.Redirect#type())`() ` Returns the type of this`Redirect`.                                                                                                                           |

| ### Inherited methods |
|-----------------------|---|
| From class` `[java.lang.Object](https://developer.android.com/reference/java/lang/Object)` ` |--------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | ` `[Object](https://developer.android.com/reference/java/lang/Object)          | ` `[clone](https://developer.android.com/reference/java/lang/Object#clone())`() ` Creates and returns a copy of this object.                                                                                                                                                      | | ` boolean`                                                                     | ` `[equals](https://developer.android.com/reference/java/lang/Object#equals(java.lang.Object))`(`[Object](https://developer.android.com/reference/java/lang/Object)` obj) ` Indicates whether some other object is "equal to" this one.                                           | | ` void`                                                                        | ` `[finalize](https://developer.android.com/reference/java/lang/Object#finalize())`() ` Called by the garbage collector on an object when garbage collection determines that there are no more references to the object.                                                          | | ` final `[Class](https://developer.android.com/reference/java/lang/Class)`<?>` | ` `[getClass](https://developer.android.com/reference/java/lang/Object#getClass())`() ` Returns the runtime class of this`Object`.                                                                                                                                                | | ` int`                                                                         | ` `[hashCode](https://developer.android.com/reference/java/lang/Object#hashCode())`() ` Returns a hash code value for the object.                                                                                                                                                 | | ` final void`                                                                  | ` `[notify](https://developer.android.com/reference/java/lang/Object#notify())`() ` Wakes up a single thread that is waiting on this object's monitor.                                                                                                                            | | ` final void`                                                                  | ` `[notifyAll](https://developer.android.com/reference/java/lang/Object#notifyAll())`() ` Wakes up all threads that are waiting on this object's monitor.                                                                                                                         | | ` `[String](https://developer.android.com/reference/java/lang/String)          | ` `[toString](https://developer.android.com/reference/java/lang/Object#toString())`() ` Returns a string representation of the object.                                                                                                                                            | | ` final void`                                                                  | ` `[wait](https://developer.android.com/reference/java/lang/Object#wait(long,%20int))`(long timeoutMillis, int nanos) ` Causes the current thread to wait until it is awakened, typically by being*notified* or*interrupted*, or until a certain amount of real time has elapsed. | | ` final void`                                                                  | ` `[wait](https://developer.android.com/reference/java/lang/Object#wait(long))`(long timeoutMillis) ` Causes the current thread to wait until it is awakened, typically by being*notified* or*interrupted*, or until a certain amount of real time has elapsed.                   | | ` final void`                                                                  | ` `[wait](https://developer.android.com/reference/java/lang/Object#wait())`() ` Causes the current thread to wait until it is awakened, typically by being*notified* or*interrupted*.                                                                                             | ||

## Fields

### INHERIT

Added in[API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public static final ProcessBuilder.Redirect INHERIT
```

Indicates that subprocess I/O source or destination will be the same as those of the current process. This is the normal behavior of most operating system command interpreters (shells).

It will always be true that  

     Redirect.INHERIT.file() == null &&
     Redirect.INHERIT.type() == Redirect.Type.INHERIT
     
<br />

<br />

### PIPE

Added in[API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public static final ProcessBuilder.Redirect PIPE
```

Indicates that subprocess I/O will be connected to the current Java process over a pipe. This is the default handling of subprocess standard I/O.

It will always be true that  

     Redirect.PIPE.file() == null &&
     Redirect.PIPE.type() == Redirect.Type.PIPE
     
<br />

<br />

## Public methods

### appendTo

Added in[API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public static ProcessBuilder.Redirect appendTo (File file)
```

Returns a redirect to append to the specified file. Each write operation first advances the position to the end of the file and then writes the requested data. Whether the advancement of the position and the writing of the data are done in a single atomic operation is system-dependent and therefore unspecified.

It will always be true that  

     Redirect.appendTo(file).file() == file &&
     Redirect.appendTo(file).type() == Redirect.Type.APPEND
     
<br />

<br />

|                     Parameters                     ||
|--------|--------------------------------------------|
| `file` | `File`: The`File`for the`Redirect`. <br /> |

|                                                                         Returns                                                                         ||
|------------------------------------------------------------------------------------------------------|---------------------------------------------------|
| [ProcessBuilder.Redirect](https://developer.android.com/reference/java/lang/ProcessBuilder.Redirect) | a redirect to append to the specified file <br /> |

|                                                            Throws                                                             ||
|------------------------------------------------------------------------------------------------|-------------------------------|
| [NullPointerException](https://developer.android.com/reference/java/lang/NullPointerException) | if the specified file is null |

### equals

Added in[API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public boolean equals (Object obj)
```

Compares the specified object with this`Redirect`for equality. Returns`true`if and only if the two objects are identical or both objects are`Redirect`instances of the same type associated with non-null equal`File`instances.

<br />

|                             Parameters                              ||
|-------|--------------------------------------------------------------|
| `obj` | `Object`: the reference object with which to compare. <br /> |

|                                         Returns                                          ||
|-----------|-------------------------------------------------------------------------------|
| `boolean` | `true`if this object is the same as the obj argument;`false`otherwise. <br /> |

### file

Added in[API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public File file ()
```

Returns the[File](https://developer.android.com/reference/java/io/File)source or destination associated with this redirect, or`null`if there is no such file.

<br />

|                                                                    Returns                                                                    ||
|--------------------------------------------------------------|---------------------------------------------------------------------------------|
| [File](https://developer.android.com/reference/java/io/File) | the file associated with this redirect, or`null`if there is no such file <br /> |

### from

Added in[API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public static ProcessBuilder.Redirect from (File file)
```

Returns a redirect to read from the specified file.

It will always be true that  

     Redirect.from(file).file() == file &&
     Redirect.from(file).type() == Redirect.Type.READ
     
<br />

<br />

|                     Parameters                     ||
|--------|--------------------------------------------|
| `file` | `File`: The`File`for the`Redirect`. <br /> |

|                                                                         Returns                                                                         ||
|------------------------------------------------------------------------------------------------------|---------------------------------------------------|
| [ProcessBuilder.Redirect](https://developer.android.com/reference/java/lang/ProcessBuilder.Redirect) | a redirect to read from the specified file <br /> |

|                                                            Throws                                                             ||
|------------------------------------------------------------------------------------------------|-------------------------------|
| [NullPointerException](https://developer.android.com/reference/java/lang/NullPointerException) | if the specified file is null |

### hashCode

Added in[API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public int hashCode ()
```

Returns a hash code value for this`Redirect`.

<br />

|                      Returns                       ||
|-------|---------------------------------------------|
| `int` | a hash code value for this`Redirect` <br /> |

### to

Added in[API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public static ProcessBuilder.Redirect to (File file)
```

Returns a redirect to write to the specified file. If the specified file exists when the subprocess is started, its previous contents will be discarded.

It will always be true that  

     Redirect.to(file).file() == file &&
     Redirect.to(file).type() == Redirect.Type.WRITE
     
<br />

<br />

|                     Parameters                     ||
|--------|--------------------------------------------|
| `file` | `File`: The`File`for the`Redirect`. <br /> |

|                                                                        Returns                                                                         ||
|------------------------------------------------------------------------------------------------------|--------------------------------------------------|
| [ProcessBuilder.Redirect](https://developer.android.com/reference/java/lang/ProcessBuilder.Redirect) | a redirect to write to the specified file <br /> |

|                                                            Throws                                                             ||
|------------------------------------------------------------------------------------------------|-------------------------------|
| [NullPointerException](https://developer.android.com/reference/java/lang/NullPointerException) | if the specified file is null |

### type

Added in[API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public abstract ProcessBuilder.Redirect.Type type ()
```

Returns the type of this`Redirect`.

<br />

|                                                                      Returns                                                                      ||
|----------------------------------------------------------------------------------------------------------------|-----------------------------------|
| [ProcessBuilder.Redirect.Type](https://developer.android.com/reference/java/lang/ProcessBuilder.Redirect.Type) | the type of this`Redirect` <br /> |