# ProcessBuilder.Redirect

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

# Redirect

```
abstract class Redirect
```

|---|------------------------------------------------------------------------------------------------------------------------|
| [kotlin.Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html)                                         ||
| ↳ | [java.lang.ProcessBuilder.Redirect](https://developer.android.com/reference/kotlin/java/lang/ProcessBuilder.Redirect#) |

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/kotlin/java/lang/ProcessBuilder.Redirect#PIPE:java.lang.ProcessBuilder.Redirect)
- the special value[Redirect.INHERIT](https://developer.android.com/reference/kotlin/java/lang/ProcessBuilder.Redirect#INHERIT:java.lang.ProcessBuilder.Redirect)
- a redirection to read from a file, created by an invocation of[Redirect.from(File)](https://developer.android.com/reference/kotlin/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/kotlin/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/kotlin/java/lang/ProcessBuilder.Redirect#appendTo(java.io.File))

<br />

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

## Summary

|                                                                                                Nested classes                                                                                                ||
|---|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|   | [Type](https://developer.android.com/reference/kotlin/java/lang/ProcessBuilder.Redirect.Type) The type of a[Redirect](https://developer.android.com/reference/kotlin/java/lang/ProcessBuilder.Redirect#). |

|                                                                                                                                                                                                 Public methods                                                                                                                                                                                                 ||
|--------------------------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| openstatic[ProcessBuilder.Redirect](https://developer.android.com/reference/kotlin/java/lang/ProcessBuilder.Redirect#)!        | [appendTo](https://developer.android.com/reference/kotlin/java/lang/ProcessBuilder.Redirect#appendTo(java.io.File))`(`file:` `[File](https://developer.android.com/reference/kotlin/java/io/File.html#)!`)` Returns a redirect to append to the specified file.                |
| open[Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html)                                         | [equals](https://developer.android.com/reference/kotlin/java/lang/ProcessBuilder.Redirect#equals(kotlin.Any))`(`other:` `[Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html)?`)` Compares the specified object with this`Redirect`for equality.         |
| open[File](https://developer.android.com/reference/kotlin/java/io/File.html#)!                                                 | [file](https://developer.android.com/reference/kotlin/java/lang/ProcessBuilder.Redirect#file())`()` Returns the[File](https://developer.android.com/reference/kotlin/java/io/File.html#)source or destination associated with this redirect, or`null`if there is no such file. |
| openstatic[ProcessBuilder.Redirect](https://developer.android.com/reference/kotlin/java/lang/ProcessBuilder.Redirect#)!        | [from](https://developer.android.com/reference/kotlin/java/lang/ProcessBuilder.Redirect#from(java.io.File))`(`file:` `[File](https://developer.android.com/reference/kotlin/java/io/File.html#)!`)` Returns a redirect to read from the specified file.                        |
| open[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)                                                 | [hashCode](https://developer.android.com/reference/kotlin/java/lang/ProcessBuilder.Redirect#hashCode())`()` Returns a hash code value for this`Redirect`.                                                                                                                      |
| openstatic[ProcessBuilder.Redirect](https://developer.android.com/reference/kotlin/java/lang/ProcessBuilder.Redirect#)!        | [to](https://developer.android.com/reference/kotlin/java/lang/ProcessBuilder.Redirect#to(java.io.File))`(`file:` `[File](https://developer.android.com/reference/kotlin/java/io/File.html#)!`)` Returns a redirect to write to the specified file.                             |
| abstract[ProcessBuilder.Redirect.Type](https://developer.android.com/reference/kotlin/java/lang/ProcessBuilder.Redirect.Type)! | [type](https://developer.android.com/reference/kotlin/java/lang/ProcessBuilder.Redirect#type())`()` Returns the type of this`Redirect`.                                                                                                                                        |

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

## Public methods

### appendTo

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

```
open static fun appendTo(file: File!): ProcessBuilder.Redirect!
```

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  

```kotlin
<code>Redirect.appendTo(file).file() == file &amp;&amp;
  Redirect.appendTo(file).type() == Redirect.Type.APPEND
  </code>
```

|                                                   Parameters                                                   ||
|--------|--------------------------------------------------------------------------------------------------------|
| `file` | [File](https://developer.android.com/reference/kotlin/java/io/File.html#)!:The`File`for the`Redirect`. |

|                                                                          Return                                                                           ||
|---------------------------------------------------------------------------------------------------------------|--------------------------------------------|
| [ProcessBuilder.Redirect](https://developer.android.com/reference/kotlin/java/lang/ProcessBuilder.Redirect#)! | a redirect to append to the specified file |

|                           Exceptions                            ||
|----------------------------------|-------------------------------|
| `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.html#ApiLevels)  

```
open fun equals(other: Any?): Boolean
```

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.

|                     Parameters                     ||
|-------|---------------------------------------------|
| `obj` | the reference object with which to compare. |

|                                                                           Return                                                                           ||
|------------------------------------------------------------------------------------|------------------------------------------------------------------------|
| [Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html) | `true`if this object is the same as the obj argument;`false`otherwise. |

### file

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

```
open fun file(): File!
```

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

|                                                                        Return                                                                        ||
|----------------------------------------------------------------------------|--------------------------------------------------------------------------|
| [File](https://developer.android.com/reference/kotlin/java/io/File.html#)! | the file associated with this redirect, or`null`if there is no such file |

### from

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

```
open static fun from(file: File!): ProcessBuilder.Redirect!
```

Returns a redirect to read from the specified file.

It will always be true that  

```kotlin
<code>Redirect.from(file).file() == file &amp;&amp;
  Redirect.from(file).type() == Redirect.Type.READ
  </code>
```

|                                                   Parameters                                                   ||
|--------|--------------------------------------------------------------------------------------------------------|
| `file` | [File](https://developer.android.com/reference/kotlin/java/io/File.html#)!:The`File`for the`Redirect`. |

|                                                                          Return                                                                           ||
|---------------------------------------------------------------------------------------------------------------|--------------------------------------------|
| [ProcessBuilder.Redirect](https://developer.android.com/reference/kotlin/java/lang/ProcessBuilder.Redirect#)! | a redirect to read from the specified file |

|                           Exceptions                            ||
|----------------------------------|-------------------------------|
| `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.html#ApiLevels)  

```
open fun hashCode(): Int
```

Returns a hash code value for this`Redirect`.

|                                                      Return                                                      ||
|----------------------------------------------------------------------------|--------------------------------------|
| [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html) | a hash code value for this`Redirect` |

### to

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

```
open static fun to(file: File!): ProcessBuilder.Redirect!
```

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  

```kotlin
<code>Redirect.to(file).file() == file &amp;&amp;
  Redirect.to(file).type() == Redirect.Type.WRITE
  </code>
```

|                                                   Parameters                                                   ||
|--------|--------------------------------------------------------------------------------------------------------|
| `file` | [File](https://developer.android.com/reference/kotlin/java/io/File.html#)!:The`File`for the`Redirect`. |

|                                                                          Return                                                                          ||
|---------------------------------------------------------------------------------------------------------------|-------------------------------------------|
| [ProcessBuilder.Redirect](https://developer.android.com/reference/kotlin/java/lang/ProcessBuilder.Redirect#)! | a redirect to write to the specified file |

|                           Exceptions                            ||
|----------------------------------|-------------------------------|
| `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.html#ApiLevels)  

```
abstract fun type(): ProcessBuilder.Redirect.Type!
```

Returns the type of this`Redirect`.

|                                                                       Return                                                                       ||
|------------------------------------------------------------------------------------------------------------------------|----------------------------|
| [ProcessBuilder.Redirect.Type](https://developer.android.com/reference/kotlin/java/lang/ProcessBuilder.Redirect.Type)! | the type of this`Redirect` |

## Properties

### INHERIT

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

```
static val INHERIT: ProcessBuilder.Redirect!
```

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  

```kotlin
<code>Redirect.INHERIT.file() == null &amp;&amp;
  Redirect.INHERIT.type() == Redirect.Type.INHERIT
  </code>
```  

### PIPE

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

```
static val PIPE: ProcessBuilder.Redirect!
```

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  

```kotlin
<code>Redirect.PIPE.file() == null &amp;&amp;
  Redirect.PIPE.type() == Redirect.Type.PIPE
  </code>
```