< prev index next >

src/java.base/share/classes/java/lang/Process.java

Print this page

        

@@ -25,10 +25,11 @@
 
 package java.lang;
 
 import java.io.*;
 import java.lang.ProcessBuilder.Redirect;
+import java.nio.channels.Pipe;
 import java.util.concurrent.CompletableFuture;
 import java.util.concurrent.TimeUnit;
 import java.util.stream.Stream;
 
 /**

@@ -149,10 +150,79 @@
      *         the subprocess
      */
     public abstract InputStream getErrorStream();
 
     /**
+     * Returns the output channel connected to the normal input of the
+     * subprocess if and only if it has been redirected using
+     * {@link ProcessBuilder#redirectInput ProcessBuilder.redirectInput}(
+     * {@link Redirect#PIPE_CHANNEL}
+     * ).
+     * It returns {@code null} otherwise.
+     * <p> Output to the channel is piped into the standard
+     * input of the process represented by this {@code Process} object
+     * <p> It is the user's responsibility to obtain the output channel and
+     * close it if {@code PIPE_CHANNEL} redirection has been used.
+     *
+     * @return the output channel connected to the normal input of the
+     *         subprocess if redirected to {@code PIPE_CHANNEL} or null otherwise
+     * @since 1.9
+     */
+    public Pipe.SinkChannel getOutputChannel() {
+        return null;
+    }
+
+    /**
+     * Returns the input channel connected to the normal output of the
+     * subprocess if and only if it has been redirected using
+     * {@link ProcessBuilder#redirectOutput ProcessBuilder.redirectOutput}(
+     * {@link Redirect#PIPE_CHANNEL}
+     * ).
+     * It returns {@code null} otherwise.
+     * <p> The channel obtains data piped from the standard
+     * output of the process represented by this {@code Process} object.
+     * <p> It is the user's responsibility to obtain the input channel and
+     * close it if {@code PIPE_CHANNEL} redirection has been used.
+     * <p> If the standard error of the subprocess has been
+     * redirected using
+     * {@link ProcessBuilder#redirectErrorStream(boolean)
+     * ProcessBuilder.redirectErrorStream}
+     * then the input channel returned by this method will receive the
+     * merged standard output and the standard error of the subprocess.
+     *
+     * @return the input channel connected to the normal output of the
+     *         subprocess if redirected from {@code PIPE_CHANNEL} or
+     *         null otherwise
+     * @since 1.9
+     */
+    public Pipe.SourceChannel getInputChannel() {
+        return null;
+    }
+
+    /**
+     * Returns the input channel connected to the error output of the
+     * subprocess if and only if it has been redirected using
+     * {@link ProcessBuilder#redirectError ProcessBuilder.redirectError}(
+     * {@link Redirect#PIPE_CHANNEL}
+     * ) and has not been redirected using
+     * {@link ProcessBuilder#redirectErrorStream(boolean)
+     * ProcessBuilder.redirectErrorStream}. It returns {@code null} otherwise.
+     * <p> The channel obtains data piped from the error
+     * output of the process represented by this {@code Process} object.
+     * <p> It is the user's responsibility to obtain the error channel and
+     * close it if {@code PIPE_CHANNEL} redirection has been used.
+     *
+     * @return the input channel connected to the error output of the
+     *         subprocess if redirected from {@code PIPE_CHANNEL} or
+     *         null otherwise
+     * @since 1.9
+     */
+    public Pipe.SourceChannel getErrorChannel() {
+        return null;
+    }
+
+    /**
      * Causes the current thread to wait, if necessary, until the
      * process represented by this {@code Process} object has
      * terminated.  This method returns immediately if the subprocess
      * has already terminated.  If the subprocess has not yet
      * terminated, the calling thread will be blocked until the
< prev index next >