ProcessBuilder.Redirect (Java SE 10 & JDK 10 )
- java.lang.Object
-
- java.lang.ProcessBuilder.Redirect
-
- Enclosing class:
- ProcessBuilder
public abstract static class ProcessBuilder.Redirect extends Object
- Since:
- 1.7
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classProcessBuilder.Redirect.TypeThe type of a
ProcessBuilder.Redirect.
-
Field Summary
Fields Modifier and Type Field Description static ProcessBuilder.RedirectDISCARDIndicates that subprocess output will be discarded.
static ProcessBuilder.RedirectINHERITIndicates that subprocess I/O source or destination will be the same as those of the current process.
static ProcessBuilder.RedirectPIPEIndicates that subprocess I/O will be connected to the current Java process over a pipe.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description static ProcessBuilder.RedirectappendTo(File file)Returns a redirect to append to the specified file.
booleanequals(Object obj)Compares the specified object with this
Redirectfor equality.Filefile()Returns the
Filesource or destination associated with this redirect, ornullif there is no such file.static ProcessBuilder.Redirectfrom(File file)Returns a redirect to read from the specified file.
inthashCode()Returns a hash code value for this
Redirect.static ProcessBuilder.Redirectto(File file)Returns a redirect to write to the specified file.
abstract ProcessBuilder.Redirect.Typetype()Returns the type of this
Redirect.
-
-
-
Field Detail
-
PIPE
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
-
INHERIT
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
-
DISCARD
public static final ProcessBuilder.Redirect DISCARD
Indicates that subprocess output will be discarded. A typical implementation discards the output by writing to an operating system specific "null file".
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 Detail
-
type
public abstract ProcessBuilder.Redirect.Type type()
Returns the type of this
Redirect.- Returns:
- the type of this
Redirect
-
file
public File file()
Returns the
Filesource or destination associated with this redirect, ornullif there is no such file.- Returns:
- the file associated with this redirect,
or
nullif there is no such file
-
from
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- Parameters:
file- TheFilefor theRedirect.- Returns:
- a redirect to read from the specified file
-
to
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- Parameters:
file- TheFilefor theRedirect.- Returns:
- a redirect to write to the specified file
-
appendTo
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- Parameters:
file- TheFilefor theRedirect.- Returns:
- a redirect to append to the specified file
-
equals
public boolean equals(Object obj)
Compares the specified object with this
Redirectfor equality. Returnstrueif and only if the two objects are identical or both objects areRedirectinstances of the same type associated with non-null equalFileinstances.- Overrides:
equalsin classObject- Parameters:
obj- the reference object with which to compare.- Returns:
trueif this object is the same as the obj argument;falseotherwise.- See Also:
Object.hashCode(),HashMap
-
hashCode
public int hashCode()
Returns a hash code value for this
Redirect.- Overrides:
hashCodein classObject- Returns:
- a hash code value for this
Redirect - See Also:
Object.equals(java.lang.Object),System.identityHashCode(java.lang.Object)
-
-
Report a bug or suggest an enhancement
For further API reference and developer documentation see the Java SE Documentation, which contains more detailed, developer-targeted descriptions with conceptual overviews, definitions of terms, workarounds, and working code examples.
Java is a trademark or registered trademark of Oracle and/or its affiliates in the US and other countries.
Copyright © 1993, 2018, Oracle and/or its affiliates, 500 Oracle Parkway, Redwood Shores, CA 94065 USA.
All rights reserved. Use is subject to license terms and the documentation redistribution policy.