- java.lang.Object
-
- java.lang.ProcessBuilder.Redirect
-
- Enclosing class:
- ProcessBuilder
public abstract static class ProcessBuilder.Redirect extends Object
Represents a source of subprocess input or a destination of subprocess output. EachRedirect
instance is one of the following:- the special value
Redirect.PIPE
- the special value
Redirect.INHERIT
- 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
Nested Classes Modifier and Type Class and Description static class
ProcessBuilder.Redirect.Type
The type of aProcessBuilder.Redirect
.
-
Field Summary
Fields Modifier and Type Field and Description static ProcessBuilder.Redirect
INHERIT
Indicates that subprocess I/O source or destination will be the same as those of the current process.static ProcessBuilder.Redirect
PIPE
Indicates that subprocess I/O will be connected to the current Java process over a pipe.
-
Method Summary
Methods Modifier and Type Method and Description static ProcessBuilder.Redirect
appendTo(File file)
Returns a redirect to append to the specified file.boolean
equals(Object obj)
Compares the specified object with thisRedirect
for equality.File
file()
Returns theFile
source or destination associated with this redirect, ornull
if there is no such file.static ProcessBuilder.Redirect
from(File file)
Returns a redirect to read from the specified file.int
hashCode()
Returns a hash code value for thisRedirect
.static ProcessBuilder.Redirect
to(File file)
Returns a redirect to write to the specified file.abstract ProcessBuilder.Redirect.Type
type()
Returns the type of thisRedirect
.
-
-
-
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
-
-
Method Detail
-
type
public abstract ProcessBuilder.Redirect.Type type()
Returns the type of thisRedirect
.- Returns:
- the type of this
Redirect
-
file
public File file()
Returns theFile
source or destination associated with this redirect, ornull
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)
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
- Returns:
- a redirect to read from the specified file
- Throws:
NullPointerException
- if the specified file is null
-
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
- Returns:
- a redirect to write to the specified file
- Throws:
NullPointerException
- if the specified file is null
-
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
- Returns:
- a redirect to append to the specified file
- Throws:
NullPointerException
- if the specified file is null
-
equals
public boolean equals(Object obj)
Compares the specified object with thisRedirect
for equality. Returnstrue
if and only if the two objects are identical or both objects areRedirect
instances of the same type associated with non-null equalFile
instances.- Overrides:
equals
in classObject
- Parameters:
obj
- the reference object with which to compare.- Returns:
true
if this object is the same as the obj argument;false
otherwise.- See Also:
Object.hashCode()
,HashMap
-
hashCode
public int hashCode()
Returns a hash code value for thisRedirect
.- Overrides:
hashCode
in classObject
- Returns:
- a hash code value for this
Redirect
- See Also:
Object.equals(java.lang.Object)
,System.identityHashCode(java.lang.Object)
-
-
Nederlandse vertaling
U hebt gevraagd om deze site in het Nederlands te bezoeken. Voor nu wordt alleen de interface vertaald, maar nog niet alle inhoud.Als je me wilt helpen met vertalingen, is je bijdrage welkom. Het enige dat u hoeft te doen, is u op de site registreren en mij een bericht sturen waarin u wordt gevraagd om u toe te voegen aan de groep vertalers, zodat u de gewenste pagina's kunt vertalen. Een link onderaan elke vertaalde pagina geeft aan dat u de vertaler bent en heeft een link naar uw profiel.
Bij voorbaat dank.
Document heeft de 11/06/2005 gemaakt, de laatste keer de 04/03/2020 gewijzigd
Bron van het afgedrukte document:https://www.gaudry.be/nl/java-api-rf-java/lang/ProcessBuilder.Redirect.html
De infobrol is een persoonlijke site waarvan de inhoud uitsluitend mijn verantwoordelijkheid is. De tekst is beschikbaar onder CreativeCommons-licentie (BY-NC-SA). Meer info op de gebruiksvoorwaarden en de auteur.
Referenties
Deze verwijzingen en links verwijzen naar documenten die geraadpleegd zijn tijdens het schrijven van deze pagina, of die aanvullende informatie kunnen geven, maar de auteurs van deze bronnen kunnen niet verantwoordelijk worden gehouden voor de inhoud van deze pagina.
De auteur Deze site is als enige verantwoordelijk voor de manier waarop de verschillende concepten, en de vrijheden die met de referentiewerken worden genomen, hier worden gepresenteerd. Vergeet niet dat u meerdere broninformatie moet doorgeven om het risico op fouten te verkleinen.