Process.getErrorStream() has the following syntax.
public abstract InputStream getErrorStream()
In the following code shows how to use Process.getErrorStream() method.
//from w ww. j a va 2 s .c om import java.io.InputStream; public class Main { public static void main(String[] args) { try { // create a new process Process p = Runtime.getRuntime().exec("notepad.exe"); // get the error stream of the process and print it InputStream error = p.getErrorStream(); for (int i = 0; i < error.available(); i++) { System.out.println(error.read()); } // wait for 10 seconds and then destroy the process Thread.sleep(10000); p.destroy(); } catch (Exception ex) { ex.printStackTrace(); } } }