On this page
Class ProcessBuilder.Redirect
- Enclosing class:
-
ProcessBuilder
public abstract static class ProcessBuilder.Redirect extends Object
Redirect
instance is one of the following:
- the special value
Redirect.PIPE
- the special value
Redirect.INHERIT
- the special value
Redirect.DISCARD
- a redirection to read from a file, created by an invocation of
Redirect.from(File)
- a redirection to write to a file, created by an invocation of
Redirect.to(File)
- a redirection to append to a file, created by an invocation of
Redirect.appendTo(File)
Each of the above categories has an associated unique Type
.
- Since:
- 1.7
Nested Class Summary
Modifier and Type | Class | Description |
---|---|---|
static enum |
ProcessBuilder.Redirect.Type |
The type of a ProcessBuilder.Redirect .
|
Field Summary
Modifier and Type | Field | Description |
---|---|---|
static final ProcessBuilder.Redirect |
DISCARD |
Indicates that subprocess output will be discarded.
|
static final ProcessBuilder.Redirect |
INHERIT |
Indicates that subprocess I/O source or destination will be the same as those of the current process.
|
static final ProcessBuilder.Redirect |
PIPE |
Indicates that subprocess I/O will be connected to the current Java process over a pipe.
|
Method Summary
Modifier and Type | Method | Description |
---|---|---|
static ProcessBuilder.Redirect |
appendTo |
Returns a redirect to append to the specified file.
|
boolean |
equals |
Compares the specified object with this Redirect for equality.
|
File |
file() |
Returns the File source or destination associated with this redirect, or null if there is no such file.
|
static ProcessBuilder.Redirect |
from |
Returns a redirect to read from the specified file.
|
int |
hashCode() |
Returns a hash code value for this Redirect .
|
static ProcessBuilder.Redirect |
to |
Returns a redirect to write to the specified file.
|
abstract ProcessBuilder.Redirect.Type |
type() |
Returns the type of this Redirect .
|
Field Details
PIPE
public static final ProcessBuilder.Redirect PIPE
It will always be true that
Redirect.PIPE.file() == null &&
Redirect.PIPE.type() == Redirect.Type.PIPE
INHERIT
public static final ProcessBuilder.Redirect INHERIT
It will always be true that
Redirect.INHERIT.file() == null &&
Redirect.INHERIT.type() == Redirect.Type.INHERIT
DISCARD
public static final ProcessBuilder.Redirect DISCARD
It will always be true that
Redirect.DISCARD.file() is the filename appropriate for the operating system
and may be null &&
Redirect.DISCARD.type() == Redirect.Type.WRITE
- Since:
- 9
Method Details
type
public abstract ProcessBuilder.Redirect.Type type()
Redirect
.
- Returns:
-
the type of this
Redirect
file
public File file()
File
source or destination associated with this redirect, or null
if there is no such file.
- Returns:
-
the file associated with this redirect, or
null
if there is no such file
from
public static ProcessBuilder.Redirect from(File file)
It will always be true that
Redirect.from(file).file() == file &&
Redirect.from(file).type() == Redirect.Type.READ
- Parameters:
file
- TheFile
for theRedirect
.- Returns:
- a redirect to read from the specified file
to
public static ProcessBuilder.Redirect to(File file)
It will always be true that
Redirect.to(file).file() == file &&
Redirect.to(file).type() == Redirect.Type.WRITE
- Parameters:
file
- TheFile
for theRedirect
.- Returns:
- a redirect to write to the specified file
appendTo
public static ProcessBuilder.Redirect appendTo(File file)
It will always be true that
Redirect.appendTo(file).file() == file &&
Redirect.appendTo(file).type() == Redirect.Type.APPEND
- Parameters:
file
- TheFile
for theRedirect
.- Returns:
- a redirect to append to the specified file
equals
public boolean equals(Object obj)
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.
hashCode
public int hashCode()
Redirect
.
© 1993, 2023, Oracle and/or its affiliates. All rights reserved.
Documentation extracted from Debian's OpenJDK Development Kit package.
Licensed under the GNU General Public License, version 2, with the Classpath Exception.
Various third party code in OpenJDK is licensed under different licenses (see Debian package).
Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
https://docs.oracle.com/en/java/javase/21/docs/api/java.base/java/lang/ProcessBuilder.Redirect.html