Java Process.getOutputStream()

Syntax

Process.getOutputStream() has the following syntax.

public abstract OutputStream getOutputStream()

Example

In the following code shows how to use Process.getOutputStream() method.


/*  w ww  .j  a  v a  2s  .  c  o  m*/
import java.io.BufferedOutputStream;
import java.io.OutputStream;

public class Main {

   public static void main(String[] args) {
      try {
         // create a new process
         Process p = Runtime.getRuntime().exec("notepad.exe");

         // get the output stream
         OutputStream out = p.getOutputStream();

         // close the output stream
         System.out.println("Closing the output stream...");
         out.close();

      } catch (Exception ex) {
         ex.printStackTrace();
      }

   }
}

The code above generates the following result.





















Home »
  Java Tutorial »
    java.lang »




Boolean
Byte
Character
Class
Double
Enum
Float
Integer
Long
Math
Number
Object
Package
Process
ProcessBuilder
Runnable
Runtime
SecurityManager
Short
StackTraceElement
StrictMath
String
StringBuffer
StringBuilder
System
Thread
ThreadGroup
ThreadLocal
Throwable