模块 java.base
 java.lang

类 ProcessBuilder.Redirect

java.lang.Object
java.lang.ProcessBuilder.Redirect
封闭类:
ProcessBuilder

public abstract static class ProcessBuilder.Redirect extends Object
表示子流程输入的来源或子流程输出的目的地。每个 Redirect 实例都是以下之一:

上述每个类别都有一个关联的唯一 Type

自从:
1.7
  • 字段详细信息

    • PIPE

      public static final ProcessBuilder.Redirect  PIPE
      指示子进程 I/O 将通过管道连接到当前 Java 进程。这是子进程标准 I/O 的默认处理。

      永远是真的

       
       Redirect.PIPE.file() == null &&
       Redirect.PIPE.type() == Redirect.Type.PIPE
        
    • INHERIT

      public static final ProcessBuilder.Redirect  INHERIT
      指示子进程 I/O 源或目标将与当前进程的相同。这是大多数操作系统命令解释器(shell)的正常行为。

      永远是真的

       
       Redirect.INHERIT.file() == null &&
       Redirect.INHERIT.type() == Redirect.Type.INHERIT
        
    • DISCARD

      public static final ProcessBuilder.Redirect  DISCARD
      指示子流程输出将被丢弃。典型的实现通过写入操作系统特定的“空文件”来丢弃输出。

      永远是真的

       
       Redirect.DISCARD.file() is the filename appropriate for the operating system
       and may be null &&
       Redirect.DISCARD.type() == Redirect.Type.WRITE
        
      自从:
      9
  • 方法详情

    • type

      public abstract ProcessBuilder.Redirect.Type  type()
      返回此 Redirect 的类型。
      返回:
      这个Redirect的类型
    • file

      public File  file()
      返回与此重定向关联的 File 源或目标,如果没有此类文件,则返回 null
      返回:
      与此重定向关联的文件,如果没有此类文件,则返回 null
    • from

      public static ProcessBuilder.Redirect  from(File  file)
      返回从指定文件读取的重定向。

      永远是真的

       
       Redirect.from(file).file() == file &&
       Redirect.from(file).type() == Redirect.Type.READ
        
      参数:
      file - RedirectFile
      返回:
      从指定文件中读取的重定向
    • to

      public static ProcessBuilder.Redirect  to(File  file)
      返回写入指定文件的重定向。如果子进程启动时指定的文件存在,则其之前的内容将被丢弃。

      永远是真的

       
       Redirect.to(file).file() == file &&
       Redirect.to(file).type() == Redirect.Type.WRITE
        
      参数:
      file - RedirectFile
      返回:
      写入指定文件的重定向
    • appendTo

      public static ProcessBuilder.Redirect  appendTo(File  file)
      返回附加到指定文件的重定向。每个写操作首先将位置前进到文件的末尾,然后写入请求的数据。位置的推进和数据的写入是否在单个原子操作中完成是系统相关的,因此未指定。

      永远是真的

       
       Redirect.appendTo(file).file() == file &&
       Redirect.appendTo(file).type() == Redirect.Type.APPEND
        
      参数:
      file - RedirectFile
      返回:
      附加到指定文件的重定向
    • equals

      public boolean equals(Object  obj)
      比较指定对象与 this Redirect 是否相等。返回 true 当且仅当两个对象相同或两个对象都是 Redirect 相同类型的实例与非 null 相等的 File 实例相关联。
      重写:
      equals 在类 Object
      参数:
      obj - 要比较的参考对象。
      返回:
      true 如果此对象与 obj 参数相同; false否则。
      参见:
    • hashCode

      public int hashCode()
      返回此 Redirect 的哈希码值。
      重写:
      hashCode 在类 Object
      返回:
      这个 Redirect 的哈希码值
      参见: