Class ProcessBuilder.Redirect
java.lang.Object
java.lang.ProcessBuilder.Redirect
- Enclosing class:
ProcessBuilder
Represents a source of subprocess input or a destination ofsubprocess output.Each
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 uniqueType.
- Since:
- 1.7
Nested Class Summary
Nested ClassesField Summary
FieldsModifier and TypeFieldDescriptionstatic finalProcessBuilder.RedirectIndicates that subprocess output will be discarded.static finalProcessBuilder.RedirectIndicates that subprocess I/O source or destination will be thesame as those of the current process.static finalProcessBuilder.RedirectIndicates that subprocess I/O will be connected to thecurrent Java process over a pipe.Method Summary
Modifier and TypeMethodDescriptionstaticProcessBuilder.RedirectReturns a redirect to append to the specified file.booleanCompares the specified object with thisRedirectforequality.file()Returns theFilesource or destination associatedwith this redirect, ornullif there is no such file.staticProcessBuilder.RedirectReturns a redirect to read from the specified file.inthashCode()Returns a hash code value for thisRedirect.staticProcessBuilder.RedirectReturns a redirect to write to the specified file.abstractProcessBuilder.Redirect.Typetype()Returns the type of thisRedirect.
Field Details
PIPE
Indicates that subprocess I/O will be connected to thecurrent 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.PIPEINHERIT
Indicates that subprocess I/O source or destination will be thesame as those of the current process. This is the normalbehavior of most operating system command interpreters (shells).It will always be true that
Redirect.INHERIT.file() == null && Redirect.INHERIT.type() == Redirect.Type.INHERITDISCARD
Indicates that subprocess output will be discarded.A typical implementation discards the output by writing toan operating system specific "null file".It will always be true that
Redirect.DISCARD.file() != null && // is the filename appropriate for the operating system Redirect.DISCARD.type() == Redirect.Type.WRITE;- Since:
- 9
Method Details
type
Returns the type of thisRedirect.- Returns:
- the type of this
Redirect
file
from
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
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
Returns a redirect to append to the specified file.Each write operation first advances the position to theend of the file and then writes the requested data.Whether the advancement of the position and the writingof the data are done in a single atomic operation issystem-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
Compares the specified object with thisRedirectforequality. Returnstrueif and only if the twoobjects are identical or both objects areRedirectinstances of the same type associated with non-null equalFileinstances.hashCode